#!/usr/bin/env pypy3 # -*- coding: utf-8 -*- import random import string MAX_L = 5 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 generate_random_pair(digits): s = "" t = "" while s == t: s = generate_random_string(digits) t = generate_random_string(digits) return s, t def birthday_attack(a, b, digits_lim=MAX_L): hash_s = -1 hash_t = -2 f = lambda x: compute_hash(x, a, b) while hash_s != hash_t: d = random.randint(1, digits_lim) s, t = generate_random_pair(d) hash_s, hash_t = map(f, (s, t)) return s, t def main(): a, b = map(int, input().split()) s, t = birthday_attack(a, b) print(s) print(t) if __name__ == '__main__': main()