Horror Story
Limits: 2 sec., 256 MiB
You are the teacher in the primary school. One day you went to the mountains with your students. It was hard to keep track of everyone, so you decided to hash all names. More specifically, you asked kids to write their nicknames on the paper and counted the number of times each letter appears on the list. All nicknames are different and consist only of the first \(k\) letters of the alphabet.
On the way back, you wanted to check the hash and asked kids to write their nicknames once again. The new hash appeared to be different because some ghost mixed into the group under a new nickname.
Given the hash you got first time and new list of nicknames, find the name of the ghost or tell that it is impossible to spot him uniquely.
Input
First line contains two integers \(n\) and \(k\) – number of nicknames and the alphabet size.
Second line contains \(n\) strings – nicknames on the list. Each one consists of lowercase letters only and have at most 20 characters.
Third line contains \(k\) integers – the number of times each letter (in alphabet order) appeared in the list before ghost mixed in.
Output
The nickname of the ghost, or
Someone call SCP Foundation
if it is impossible to spot the
ghost uniquely.
Constraints
\(2 \le n \le 10^{5}\),
\(1 \le k \le 26\).
Samples
Input (stdin) | Output (stdout) |
---|---|
4 3 baca acaba caca ac 6 2 3 | caca |
Input (stdin) | Output (stdout) |
---|---|
6 2 a b aa ab ba bb 4 4 | Someone call SCP Foundation |
Submit a solution
Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
---|
Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
---|