a = input()
b = 1
c = 0
if eval(a)>=24:#当a大于等于24时,后六位都是940313,因此直接输出
print(940313)
else:
for i in range(1,eval(a)+1):
b *= i
c += b
print(c%1000000)
a = input()
b = 1
c = 0
if eval(a)>=24:#当a大于等于24时,后六位都是940313,因此直接输出
print(940313)
else:
for i in range(1,eval(a)+1):
b *= i
c += b
print(c%1000000)