#!/usr/bin/env pypy3 # -*- coding: utf-8 -*- import itertools import random import string mydict=dict() max=1000000 def compute_hash(s, a, b): h = 0 n = len(s) for i, c in enumerate(s): h += ((ord(c) % b) * pow(a, n - 1 - i, b)) % b h %= b return h def generate_random_string(digits, source=string.ascii_lowercase): return "".join(random.choice(source) for _ in range(digits)) def cycledetection(a,b): for i in range(max): #print(i) tmp=a**i%b if tmp in mydict: return 0,mydict[tmp]+i mydict[tmp]=-i def main(): a, b = map(int, input().split()) s, t = cycledetection(a, b) while True: tmp=generate_random_string(t+1) if tmp[s]!=tmp[t]: break print(tmp) tmp=list(tmp) x=tmp[s] y=tmp[t] tmp[s]=y tmp[t]=x print("".join(tmp)) if __name__ == '__main__': main()