m = int(raw_input()) a = 2017 % m b = (a*a) % m c = 1 for _ in range(2017): c = (b*c) % m print (a+c) % m