#include <fstream>
#include <iostream>
#include <cstring>
using namespace std;
ifstream fin( "rot.in" );
bool DEBUG = false;
int main() {
int N, i, inLength;
string inString, outString;
fin >> N;
while (N > 0) {
fin >> inString;
DEBUG && cout << "Got Data -- N: " << N
<< "\tString: " << inString << endl;
outString = inString;
inLength = inString.length();
for (i=0; i < inLength; i++) {
outString[inLength -1 -i] = inString[i];
}
DEBUG && cout << "REV: " << outString << endl;
for (i=0; i < inLength; i++) {
if (outString[i] >= 'A' && outString[i] <= 'Z') {
if (int(outString[i] - 'A' + N) % 28 < 26) {
outString[i] = 'A' + (outString[i] - 'A' + N) % 28;
} else if ((outString[i] - 'A' + N) % 28 == 26) {
outString[i] = '_';
} else {
outString[i] = '.';
}
} else if (outString[i] == '_') {
if (N == 1) {
outString[i] = '.';
} else {
outString[i] = 'A' + N - 2;
}
} else {
if (N == 27) {
outString[i] = '_';
} else {
outString[i] = 'A' + N - 1;
}
}
}
DEBUG && cout << "OUT: " << outString << "\nIN : " << inString << endl;
cout << outString << endl;
fin >> N;
}
return 0;
}