This question is silly, because the pressed letters correspond to the unique numeric buttons.
Code:
# Include <cstdio> # include <cstring> # include <iostream> # include <cmath> # include <string> # include <vector> # include <map> # include <algorithm> using namespace STD; inline int RINT () {int X; scanf ("% d", & X); Return X;} inline int max (int x, int y) {return (x> Y )? X: Y;} inline int min (int x, int y) {return (x <Y )? X: Y ;}# define for (I, a, B) for (INT I = (a); I <= (B); I ++) # define Ford (I, a, B) for (INT I = (a); I >= (B); I --) # define rep (X) for (INT I = 0; I <(x); I ++) typedef long int64; # define Inf (1 <30) const double EPS = 1e-8; # define bug (s) cout <# S <"=" <S <"# define maxn 5002 # define maxm 5002int tonum [] = {2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 9, 9, 9 }; char ch [maxm] [10]; char di [maxn] [10]; Map <int, int> DIC; int main () {int T = RINT (); while (t --) {dic. clear (); int n = RINT (); int M = RINT (); rep (n) {scanf ("% s", di [I]);} rep (m) {scanf ("% s", CH [I]); int ret = 0; For (int K = 0; ch [I] [k]; k ++) {ret = RET * 10 + tonum [CH [I] [k]-'a']; DIC [RET] ++ ;}} rep (N) {int ret = 0; For (int K = 0; di [I] [k]; k ++) {ret = RET * 10 + di [I] [k]-'0';} printf ("% d \ n", DIC [RET]) ;}}