a,b,c=1,0,0

exec('a,b,c=b,c,a+c;'*int(eval(input())))

print((a%(10**9+7)))
a=1

b=c=0

exec('a,b,c=b,c,a+c;'*int(eval(input())))

print((a%(10**9+7)))
a, b, c = 1, 0, 0
exec("a,b,c=b,c,a+c;" * int(eval(input())))
print((a % (10**9 + 7)))

a = 1
b = c = 0
exec("a,b,c=b,c,a+c;" * int(eval(input())))
print((a % (10**9 + 7)))

-a, b, c = 1, 0, 0 +a = 1 +b = c = 0