Neighbourly Constraints (noch nicht übersetzt)

Problem 654

Let T(n,m) be the number of m-tuples of positive integers such that the sum of any two neighbouring elements of the tuple is n.

For example, T(3,4)=8, via the following eight 4-tuples:
(1,1,1,1)
(1,1,1,2)
(1,1,2,1)
(1,2,1,1)
(1,2,1,2)
(2,1,1,1)
(2,1,1,2)
(2,1,2,1)

You are also given that T(5,5)=246, T(10,102)862820094(mod1000000007) and T(102,10)782136797(mod1000000007).

Find T(5000,1012)mod1000000007.