//line 1 "answer.cpp" #include using namespace std; using ll = long long; const vector ns = {1, 2, 5, 10, 19, 36, 69, 134, 263, 520, 1033, 2058, 4107, 8204, 16397, 32782, 65551, 131088, 262161}; const vector> primitive_polynomials = { {}, {1}, {1, 2}, {1, 3}, {3, 4}, {3, 5}, {5, 6}, {6, 7}, {4, 5, 6, 8}, {5, 9}, {7, 10}, {9, 11}, {4, 10, 11, 12}, {8, 11, 12, 13}, {2, 12, 13, 14}, {14, 15}, {11, 13, 14, 16}, {14, 17}, {11, 18}, }; vector> lfsr(ll d) { vector p = primitive_polynomials[d]; ll x = (1 << d) - 1; vector r; while (r.size() == 0 || r[0] != x) { r.push_back(x); x <<= 1; for (auto k : p) if ((x >> k) & 1) x ^= 1; if ((x >> d) & 1) x ^= (1 << d); } r.insert(find(r.begin(), r.end(), (1 << (d-1))) + 1, 0); vector> result(1 << d); for (size_t i=0; i < (1 << d); ++i) { result[r[i]] = {0, r[(i+1) % (r.size())]}; } return result; } int solve(int n) { if (n == 1) {cout << "a" << endl; return 0;} int d = (upper_bound(ns.begin(), ns.end(), n) - ns.begin()) - 1; vector>> c(2); c[0] = lfsr(d); c[1] = vector>(1 << d, {-1, -1}); int l = ns[d]; int s = 0; unordered_set r; for (int x=0; x < (1 << d); ++x) r.insert(x); while (l < n) { int x = *r.begin(); while (c[1][x].first == -1) { r.erase(x); l += 1; c[1][x] = {1, c[0][x].second ^ 1}; x = c[1][x].second; } s = c[0][x].second; swap(c[0][x], c[1][x]); } pair pos = {0, s}; string ans; for (int i=d-1; i >= 0; i--) ans += ((pos.second >> i) & 1) ? 'a' : 'b'; while (ans.size() < n) { auto [t, x] = pos; auto [tn, xn] = c[t][x]; ans += (xn & 1) ? 'a' : 'b'; pos = {tn, xn}; } cout << ans << endl; return 0; } int main() { int t; cin >> t; while (t--) { int n; cin >> n; solve(n); } }