시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 591 390 343 69.293%

문제

Cryptoquote는 어떤 메시지가 있을 때, 각 알파벳을 다른 알파벳으로 변환해 암호화 하는 방법이다.

예를 들어, HPC PJVYMIY란 메시지가 있을 때, 이를 원래 메시지로 바꾼다면 ACM CONTEST가 된다.

위의 예를 바꾸는 규칙은 H=A, P=C, C=M, J=O, V=N, Y=T, M=E, I=S이다. 이처럼 Cryptoquote를 하려면, 문자와 문자 사이의 규칙이 있어야 한다.

암호화된 메시지와 문자와 문자 사이의 규칙이 주어졌을 때, 이를 원래 메시지로 바꾸는 프로그램을 작성하시오.

입력

첫째 줄에 테스트 케이스의 개수 T(1 ≤ T ≤ 1000)가 주어진다. 각 테스트 케이스는 다음과 같이 두 줄로 구성되어 있다.

테스트 케이스의 첫째 줄에는 암호화된 메시지가 주어지고, 둘째 줄에는 변환 규칙이 주어진다. 변환 규칙은 알파벳 대문자 26글자로 이루어져있고, 

첫 번째 문자는 A에 해당하는 문자, 두 번째는 B, ..., 26번째는 Z에 해당하는 문자이다. 변환 규칙은 중복되지 않는다. 암호화된 메시지에는 공백이 있을 수 있고, 이것은 원래 메시지에도 포함되어야 한다.

출력

각 테스트 케이스에 대해서 한 줄에 하나씩 원래 메시지를 출력한다.

예제 입력 1

2
HPC PJVYMIY
BLMRGJIASOPZEFDCKWYHUNXQTV
FDY GAI BG UKMY
KIMHOTSQYRLCUZPAGWJNBVDXEF

예제 출력 1

ACM CONTEST
THE SKY IS BLUE
W3sicHJvYmxlbV9pZCI6IjI3MDMiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJDcnlwdG9xdW90ZSIsImRlc2NyaXB0aW9uIjoiPHA+Q3J5cHRvcXVvdGVcdWIyOTQgXHVjNWI0XHViNWE0IFx1YmE1NFx1YzJkY1x1YzljMFx1YWMwMCBcdWM3ODhcdWM3NDQgXHViNTRjLCBcdWFjMDEgXHVjNTRjXHVkMzBjXHViY2IzXHVj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YXNlIGxldHRlcnMgZ2l2aW5nIHRoZSBjaGFyYWN0ZXIgbWFwcGluZyBmb3IgZWFjaCBsZXR0ZXIgb2YgdGhlIGFscGhhYmV0OiB0aGUgZmlyc3QgY2hhcmFjdGVyIGdpdmVzIHRoZSBtYXBwaW5nIGZvciBBLCB0aGUgc2Vjb25kIGZvciBCIGFuZCBzbyBvbi4gT25seSB1cHBlciBjYXNlIGxldHRlcnMgd2lsbCBiZSB1c2VkLiBTcGFjZXMgbWF5IGFwcGVhciBpbiB0aGUgZW5jb2RlZCBtZXNzYWdlLCBhbmQgc2hvdWxkIGJlIHByZXNlcnZlZCBpbiB0aGUgb3V0cHV0IHN0cmluZy48XC9wPlxyXG4iLCJvdXRwdXQiOiI8cD5Gb3IgZWFjaCBkYXRhIHNldCwgeW91IHNob3VsZCBnZW5lcmF0ZSBvbmUgbGluZSBvZiBvdXRwdXQgd2l0aCB0aGUgZm9sbG93aW5nIHZhbHVlczogVGhlIGRhdGEgc2V0IG51bWJlciBhcyBhIGRlY2ltYWwgaW50ZWdlciAoc3RhcnQgY291bnRpbmcgYXQgb25lKSwgYSBzcGFjZSBhbmQgdGhlIGRlY29kZWQgbWVzc2FnZS48XC9wPlxyXG4iLCJoaW50IjoiIiwib3JpZ2luYWwiOiIxIiwicHJvYmxlbV9sYW5nX2NvZGUiOiJcdWM2MDFcdWM1YjQifV0=

출처

ACM-ICPC > Regionals > North America > Greater New York Region > 2008 Greater New York Programming Contest B번