# 東京大学プログラミングコンテスト2012: F - Uinny

,

https://beta.atcoder.jp/contests/utpc2012/tasks/utpc2012_06

## implementation

#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < int(n); ++ (i))
using ll = long long;
using namespace std;

int main() {
// input
int a, b; cin >> a >> b;
// solve
auto hash = [&](string const & s) {
ll h = 0;
for (char c : s) {
h = (h * a + (c - 'a' + 1)) % b;
}
return h;
};
vector<pair<string, string> > collision;
default_random_engine gen;
unordered_map<int, string> found;
while (true) {
string s;
REP (i, 7) s += uniform_int_distribution<char>('a', 'z')(gen);
int h = hash(s);
if (found.count(h) and found[h] != s) {
collision.emplace_back(s, found[h]);
found.erase(h);
if (collision.size() == 7) break;
} else {
found[h] = s;
}
// pred
if (s == "zzzzzzz") break;
// increment
int i = 0;
while (s[i] == 'z') s[i ++] = 'a';
s[i] += 1;
}
// output
REP (x, 100) {
string s = "";
REP (i, 7) {
s += (x & (1 << i) ? collision[i].first : collision[i].second);
}
cout << s << endl;
}
return 0;
}