Hidden Password

시간 제한3초메모리 제한1024 MB

요약
한 비밀번호가 주어질 때, 각각을 d만큼 카이사르 이동했을 때 서로 바뀌는 다른 비밀번호를 구하고, 유일하지 않으면 NIE를 출력한다.
난이도

보통10점 중 7점

유형
문자열, 문자열 매칭, 수학, 정수론
정답자
아직 제출이 없습니다

문제

After a successful internship, Bytholomew was hired as a senior cyber-security expert. To lead by example, he decided to finally heed his own advice and use two different passwords for his e-mail and for the Facepalm social media. Unfortunately, remembering two passwords proved too much for him. Moreover, he couldn't just plainly write the passwords somewhere, as it would be against another of his recommendations. But being a security expert, Bytholomew knew exactly what to do. He chose his favorite integer d>0d > 0 and wrote both passwords encoded with Caesar cipher with key dd.

Pleased with his work, he looked at his notes and the horrible truth dawned on him: after the encoding, the first (e-mail) password became literally the second (Facepalm) password, while the second one turned into the first one. ,,Holy moly!" -- Bytholomew exclaimed, as there was nothing more to say.

Now you too can become a security expert -- knowing the first of Bytholomew's passwords, guess the second one, if possible.

입력

The first line of input contains the number of test cases zz (1≤z≤201 \leq z \leq 20). The descriptions of the test cases follow.

Each test case is one word -- the password -- consisting of lowercase English letters, in a separate line. The password has at least 11 character and at most 200,000200\\,000 characters.

The total number of characters in all passwords does not exceed 1,000,0001\\,000\\,000.

출력

For every given password, guess and output the second one in a separate line. If the second password cannot be determined (either because there is no solution or because there is more than one), output a single word NIE instead.

힌트

The Caesar cipher means substituting each letter with the one dd places down the alphabet, treating alphabet as cyclic if necessary. E.g. for d=3d = 3 the letter a is substituted by d, b by e,...., w changes into z, x to a, y to b and z to c.

예제1

  1. 예제 1

    입력
    1
    cnffjbeq
    
    예상 출력
    password