#include #include using namespace std; int n; unordered_map key; unordered_map key2; bool isPalidrome(string name){ if(name.size() == 1){ return true; } int n = name.size(); for(int i = 0; i < n /2; i++){ if(name[i] != name[n - i -1]){ return false; } } return true; } void code(string name){ const int base = 27; const int m = 1e7 + 9; long long hashValue = 0; long long hashValue2 = 0; long long base_pow = 1; //cout< decode(string name){ const int base = 27; const int m = 1e7 + 9; long long hashValue = 0; long long base_pow = 1; long long hashValue2 = 0; for(int i = 0; i < name.size(); i++){ hashValue = (long long)((hashValue + (name[i] - 'a' + 1) * base_pow)) % m; hashValue2 = (long long)((hashValue2 + (name[name.size()-i-1] - 'a' + 1) * base_pow)) % m; base_pow = (long long)(base_pow * base) % m; } return {hashValue, hashValue2}; } // long long decodeReverse(string name){ // const int base = 27; // const int m = 1e7 + 9; // long long hashValue = 0; // long long base_pow = 1; // for(int i = name.size() - 1; i >= 0; i--){ // hashValue = (long long)((hashValue + (name[i] - 'a' + 1) * base_pow)) % m; // base_pow = (long long)(base_pow * base) % m; // } // return hashValue; // } int main(){ freopen("wordstone.in","r",stdin); freopen("wordstone.out","w",stdout); ios_base::sync_with_stdio(false); cin>>n; string name; for(int i = 0; i < n; i++){ cin>>name; code(name); } int q; cin>>q; int ans; for(int i = 0; i < q; i++){ cin>>name; //cout< k = decode(name); // cout<