Jack the Ripper
Jack the Ripper wants to send a message to the police. However, he can't write it by hand because he's worried the police will discover his identity. Instead, he plans to create the message by cutting out letters from a magazine. Your task is to develop a program that determines if it's possible to construct the given message using the magazine's letters.
Input
The first line of the input contains the integers P, H, and W, where P is the number of pages in the magazine, H is the number of lines per page, and W is the maximum length of each line. This is followed by P pages, each consisting of H lines, with each line containing up to W characters. After these pages, a line with Jack's message is provided. Each line contains at least one character. All characters are uppercase Latin letters, and in the magazine, they have uniform width and length. Pages 1 and 2 are printed on opposite sides of the same sheet, pages 3 and 4 on another sheet, and so forth. The character at line i and position j is directly behind the character at line i and position W-j+1 on the reverse side of the sheet.
Output
The program should output YES if Jack can create his message using only the letters cut out from the magazine, or NO if he cannot.