#include using namespace std; unsigned long long get_hash(string s, unsigned long long a, unsigned long long b){ unsigned long long hash = 0; for(int i = 0; i < s.size(); i++){ hash = (hash * a + s[i]) % b; } return hash; } int main(){ srand(time(NULL)); string s,s2; int i,j,a,b; unsigned long long hash,hash2; cin >> a >> b; for(i=0;i<2;i++){ s+=rand()%26 + 'a'; } cout << s << endl; hash=get_hash(s,a,b); s2="aa"; for(i=0;i<26;i++){ for(j=0;j<26;j++){ s2[0]=s2[0]+i; s2[1]=s2[1]+j; hash2=get_hash(s2,a,b); if(s!=s2 && hash==hash2){ cout << s2 << endl; break; } } if(s!=s2 && hash==hash2){ break; } } return 0; }