#include #include #include #include #define chMax 26 using namespace std; int n, Sol; unordered_map repr; unordered_map harta; int main() { for(int i=0; i>ch>>code; repr[ch]=code; } cin>>n; for(int i=1; i<=n; i++) { char ch; string code, word=""; cin>>code; for(int j=0; code[j]>='a' && code[j]<='z'; j++) word+=repr[code[j]]; harta[word]++; Sol=max(Sol, harta[word]); } cout<<(Sol==1 || Sol==0 ? -1 : Sol); }