#include #include #include #include #include #include #include using namespace std; using ll = long long; #define rep(i, j, n) for (ll i = j; i < (n); ++i) #define rrep(i, j, n) for (ll i = (n) - 1; j <= i; --i) #define all(a) a.begin(), a.end() template std::ostream &operator<<(std::ostream &os, std::vector &a) { for (size_t i = 0; i < a.size(); ++i) os << (i > 0 ? " " : "") << a[i]; return os << '\n'; } template std::istream &operator>>(std::istream &is, std::vector &a) { for (T &x : a) { is >> x; } return is; } //[[maybe_unused]] constexpr long long MOD = 998244353; // constexpr long long MOD = 1000000007; [[maybe_unused]] constexpr int INF = 0x3f3f3f3f; [[maybe_unused]] constexpr long long INFL = 0x3f3f3f3f3f3f3f3fLL; int main() { cin.tie(0)->sync_with_stdio(0); // ll a, b; cin >> a >> b; string s; char c = 0; rep(i, 0, b * 10) { s += c + 'a'; c = (c + 3) % 26; } int n = (int)s.size(); vector hash(n + 1); rep(i, 0, n) { hash[i + 1] = (hash[i] * a + s[i]) % b; } vector mp(b); rep(i, 0, n) mp[hash[i]]++; ll mx = 0, mxi = 0; rep(i, 0, b) if (mx < mp[i]) mx = mp[i], mxi = i; vector ids; rep(i, 0, n) if (hash[i] == mxi) ids.push_back(i); int id1 = ids[0], id2 = ids[1], id3 = ids[2], id4 = ids[3]; if (id2 - id1 == id4 - id3) id4 = ids[4]; string t = s.substr(0, id1) + s.substr(id3, id4 - id3) + s.substr(id2, id3 - id2) + s.substr(id1, id2 - id1) + s.substr(id4, n - id4); cout << s << '\n' << t << '\n'; }