#include <stdlib.h>
#include <stdio.h>
#include <string.h>
/**
* Auto-generated code below aims at helping you parse
* the standard input according to the problem statement.
**/
int main()
{
int L;
scanf("%d", &L);
int H;
scanf("%d", &H); fgetc(stdin);
char T[257];
fgets(T, 257, stdin);
char ROW[30][1025] = { 0 };
for (int i = 0; i < H; i++) {
fgets(ROW[i], 1025, stdin);
}
// Write an action using printf(). DON'T FORGET THE TRAILING \n
// To debug: fprintf(stderr, "Debug messages...\n");
char buf[30][1025] = { 0 };
char *p;
int l;
for (l = 0, p = &T; *p != NULL && *p != '\n'; p++, l++) {
fprintf(stderr, "Found Char %c (%d)\n", *p, *p);
for (int i = 0; i < H; i++) {
int offset = *p - 65;
if (offset > 31) {
offset = offset - 32;
}
if (offset < 0 || offset > 31) {
offset = 26;
}
char* bufp = &buf[i][0] + (l * L);
memcpy(bufp, ROW[i] + (L * offset), L);
}
}
for (int i = 0; i < sizeof(buf) && buf[i][0] != NULL; i++) {
}
return 0;
}