a,b,c=1,0,0

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

print((c%(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, b, c = 1, 0, 0
exec("a,b,c=b,c,a+c;" * (int(eval(input())) - 2))
print((c % (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)))

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