from string import ascii_lowercase
import random


def myhash(s: str, b, mod):
    h = 0
    for c in s:
        h = h*b + ord(c)
        h %= mod

    return h


def gen_str(n: int) -> str:
    return ''.join(random.choices(ascii_lowercase, k=n))


P = int(input())
B = int(input())

used = {}
k = 20
while 1:
    s = gen_str(k)
    h = myhash(s, B, P)
    if h in used:
        print(s)
        print(used[h])
        break

    used[h] = s