Chef has an array A consisting of N integers (1-based indexing). He asks you to perform the following operation M times:

	for i = 2 to N:
		Ai = Ai + Ai-1

Your task is to find the xth element of the array (i.e., Ax) after performing the above operation M times. As the answer could be large, please output it modulo 109 + 7.

-----Input-----
- The first line of input contains an integer T denoting the number of test cases.
- The first line of each test case contains three space-separated integers — N, x, and M — denoting the size of the array, index of the element you need to find, and the amount of times you need to repeat operation before finding the element, respectively. The second line contains N space-separated integers A1, A2, …, AN.

-----Output-----
For each test case, output a single line containing one integer: Ax modulo 109 + 7. 

-----Constraints-----
- 1 ≤ T ≤ 10
- 1 ≤ x ≤ N ≤ 105
- 1 ≤ M ≤ 1018 
- 1 ≤ Ai  ≤ 1018

-----Subtasks-----Subtask 1 (8 points):
- 1 ≤ x ≤ min{2, N}Subtask 2 (24 points):
- 1 ≤ N * M ≤ 106Subtask 3 (68 points):  No additional constraints

-----Example-----
Input:
2
3 2 3
1 2 3
3 3 3 
1 2 3

Output:
5
15

-----Explanation-----
Values in the array A:
- Before the operations: [1, 2, 3]
- After the first operation: [1, 3, 6]
- After the second operation: [1, 4, 10]
- After the third operation: [1, 5, 15]

Since input file can be fairly large (about 8 MB), it's recommended to use fast I/O (for example, in C++, use scanf/printf instead of cin/cout).

Starter code:

Solutions:
for _ in range(int(input())):
 n,x,m = map(int,input().split())
 a = list(map(int,input().split()))
 for _ in range(m):
  for i in range(1,n):
   a[i] = a[i] + a[i-1]
 print(a[x-1]%(10**9+7))

def modInverse(a, m) : 
 m0 = m 
 y = 0
 x = 1

 if (m == 1) : 
  return 0

 while (a > 1) : 
  q = a // m 

  t = m 
  m = a % m 
  a = t 
  t = y 
  y = x - q * y 
  x = t 
 if (x < 0) : 
  x = x + m0 

 return x
p=10**9+7
f=[1]*(100000+1)
for i in range(1,100000+1):
 f[i]=i*f[i-1]
 if f[i]>p:
  f[i]=f[i]%p

for _ in range(int(input())):
 n,x,m=map(int,input().split( ))
 m=m%p
 a=list(map(int,input().split( ))) 
 pre=[1]*(x)
 for i in range(1,x):
  pre[i]=pre[i-1]*((m+(i-1)))*f[i-1]
  inv=modInverse(f[i],p)
  pre[i]=(pre[i]*inv)%p
 ans=0
 j=0 
 for i in range(x-1,-1,-1):
  ans+=a[j]*pre[i]
  if ans>p:
   ans=ans%p
  j+=1
 print(ans%p)

def modInverse(a, m) : 
 m0 = m 
 y = 0
 x = 1

 if (m == 1) : 
  return 0

 while (a > 1) : 
  q = a // m 

  t = m 
  m = a % m 
  a = t 
  t = y 
  y = x - q * y 
  x = t 
 if (x < 0) : 
  x = x + m0 

 return x
p=10**9+7
f=[1]*(100000+1)
for i in range(1,100000+1):
 f[i]=i*f[i-1]
 if f[i]>p:
  f[i]=f[i]%p

for _ in range(int(input())):
 n,x,m=map(int,input().split( ))
 m=m%p
 a=list(map(int,input().split( ))) 
 pre=[1]*(x)
 for i in range(1,x):
  pre[i]=pre[i-1]*((m+(i-1)))*f[i-1]
  inv=modInverse(f[i],p)
  pre[i]=(pre[i]*inv)%p
 ans=0
 j=0 
 for i in range(x-1,-1,-1):
  ans+=a[j]*pre[i]
  if ans>p:
   ans=ans%p
  j+=1
 print(ans%p)

p=10**9+7
f=[1]*(100000+1)
for i in range(1,100000+1):
 f[i]=i*f[i-1]
 if f[i]>p:
  f[i]=f[i]%p

for _ in range(int(input())):
 n,x,m=map(int,input().split( ))
 m=m%p
 a=list(map(int,input().split( ))) 
 pre=[1]*(x)
 for i in range(1,x):
  pre[i]=((((pre[i-1]%p)*((m+(i-1))%p))%p)%p*(f[i-1]%p))%p
  pre[i]=pre[i]//f[i]
 ans=0
 j=0 
 for i in range(x-1,-1,-1):
  ans+=a[j]*pre[i]
  if ans>p:
   ans=ans%p
  j+=1
 print(ans%p)

p=10**9+7
f=[1]*(100000+1)
for i in range(1,100000+1):
 f[i]=i*f[i-1]
 if f[i]>p:
  f[i]=f[i]%p

for _ in range(int(input())):
 n,x,m=map(int,input().split( ))
 m=m%p
 a=list(map(int,input().split( ))) 
 pre=[1]*(x)
 for i in range(1,x):
  pre[i]=pre[i-1]*(m+(i-1))*f[i-1]
  if pre[i]>p:
   pre[i]=pre[i]%p
  pre[i]=pre[i]//f[i]
 ans=0
 j=0 
 for i in range(x-1,-1,-1):
  ans+=a[j]*pre[i]
  if ans>p:
   ans=ans%p
  j+=1
 print(ans%p)

p=10**9+7
f=[1]*(100000+1)
for i in range(1,100000+1):
 f[i]=i*f[i-1]
 if f[i]>=p:
  f[i]=f[i]%p

for _ in range(int(input())):
 n,x,m=map(int,input().split( ))
 m=m%p
 a=list(map(int,input().split( ))) 
 pre=[1]*(x)
 for i in range(1,x):
  pre[i]=pre[i-1]*(m+(i-1))*f[i-1]
  if pre[i]>=p:
   pre[i]=pre[i]%p
  pre[i]=pre[i]//f[i]
 ans=0
 j=0 
 for i in range(x-1,-1,-1):
  ans+=a[j]*pre[i]
  if ans>=p:
   ans=ans%p
  j+=1
 print(ans%p)

p=10**9+7
f=[1]*(100000+1)
for i in range(1,100000):
 f[i]=i*f[i-1]
 if f[i]>=p:
  f[i]=f[i]%p

for _ in range(int(input())):
 n,x,m=map(int,input().split( ))
 m=m%p
 a=list(map(int,input().split( ))) 
 pre=[1]*(x)
 for i in range(1,x):
  pre[i]=pre[i-1]*(m+(i-1))*f[i-1]
  if pre[i]>=p:
   pre[i]=pre[i]%p
  pre[i]=pre[i]//f[i]
 ans=0
 j=0 
 for i in range(x-1,-1,-1):
  ans+=a[j]*pre[i]
  if ans>=p:
   ans=ans%p
  j+=1
 print(ans%p)

p=10**9+7
f=[1]*(100000+1)
for i in range(1,100000):
 f[i]=i*f[i-1]
 if f[i]>=p:
  f[i]=f[i]%p

for _ in range(int(input())):
 n,x,m=map(int,input().split( ))
 a=list(map(int,input().split( ))) 
 pre=[1]*(x+1)
 for i in range(1,x):
  pre[i]=pre[i-1]*(m+(i-1))*f[i-1]
  if pre[i]>=p:
   pre[i]=pre[i]%p
  pre[i]=pre[i]//f[i]
 ans=0
 j=0 
 for i in range(x-1,-1,-1):
  ans+=a[j]*pre[i]
  if ans>=p:
   ans=ans%p
  j+=1
 print(ans)

p=10**9+7
f=[1]*(100+1)
for i in range(1,100):
 f[i]=i*f[i-1]
 if f[i]>=p:
  f[i]=f[i]%p

for _ in range(int(input())):
 n,x,m=map(int,input().split( ))
 a=list(map(int,input().split( ))) 
 pre=[1]*(x+1)
 for i in range(1,x):
  pre[i]=pre[i-1]*(m+(i-1))*f[i-1]
  if pre[i]>=p:
   pre[i]=pre[i]%p
  pre[i]=pre[i]//f[i]
 ans=0
 j=0 
 for i in range(x-1,-1,-1):
  ans+=a[j]*pre[i]
  if ans>=p:
   ans=ans%p
  j+=1
 print(ans)

import math
T=int(input())
for i in range(T):
 n,x,m=list(map(int,input().split()))
 l1=[int(i) for i in input().split()]
 if x==1:
  l1[0]=l1[0]%1000000007
  print(l1[0])
 elif x==2:
  m=m%1000000007
  l1[0]=l1[0]%1000000007
  l1[1]=(l1[1]%1000000007+l1[0]*m%1000000007)%1000000007
  print(l1[1])
 else:
  m=m%1000000007
  c=-1
  y=0
  q=1
  f=1
  y=(l1[x-1]%1000000007)
  for j in range(x-2,-1,-1):
   c=c+1
   q=(q*((m+c)%1000000007))%1000000007
   q=(q*pow(c+1,1000000005,1000000007))%1000000007
   y=(y+(q*(l1[j]%1000000007))%1000000007)%1000000007
   #print(q,s,c)
   #print(y,s,l1[j])
  print(y%1000000007)
  



T=int(input())
for i in range(T):
 n,x,m=list(map(int,input().split()))
 l1=[int(i) for i in input().split()]
 if x==1:
  l1[0]=l1[0]%1000000007
  print(l1[0])
 elif x==2:
  m=m%1000000007
  l1[0]=l1[0]%1000000007
  l1[1]=(l1[1]%1000000007+l1[0]*m%1000000007)%1000000007
  print(l1[1])
 else:
  m=m%1000000007
  c=-1
  y=0
  q=1
  y=(l1[x-1]%1000000007)
  for j in range(x-2,-1,-1):
   c=c+1
   q=(q*((m+c)%1000000007))%1000000007
   #print(q)
   s=(q*pow(c,1000000005,1000000007))%1000000007
   y=(y+(s*(l1[j]%1000000007))%1000000007)%1000000007
   #print(y,s,l1[j])
  print(y)
  



T=int(input())
for i in range(T):
 n,x,m=list(map(int,input().split()))
 l1=[int(i) for i in input().split()]
 if x==1:
  l1[0]=l1[0]%1000000007
  print(l1[0])
 elif x==2:
  m=m%1000000007
  l1[0]=l1[0]%1000000007
  l1[1]=(l1[1]%1000000007+l1[0]*m%1000000007)%1000000007
  print(l1[1])
 else:
  m=m%1000000007
  c=-1
  y=0
  q=1
  y=(l1[x-1]%1000000007)
  for j in range(x-2,-1,-1):
   c=c+1
   q=(q*((m+c)%1000000007))%1000000007
   print(q)
   s=(q*pow(c,1000000005,1000000007))%1000000007
   y=(y+(s*(l1[j]%1000000007))%1000000007)%1000000007
   #print(y,s,l1[j])
  print(y)
  



T=int(input())
for i in range(T):
 n,x,m=list(map(int,input().split()))
 l1=[int(i) for i in input().split()]
 if x==1:
  l1[0]=l1[0]%1000000007
  print(l1[0])
 elif x==2:
  m=m%1000000007
  l1[0]=l1[0]%1000000007
  l1[1]=(l1[1]%1000000007+l1[0]*m%1000000007)%1000000007
  print(l1[1])
 '''else:
     m=m%1000000007
     c=-1
     y=0
     q=1
     y=(l1[x-1]%1000000007)
     for j in range(x-2,-1,-1):
      c=c+1
      q=(q*((m+c)%1000000007))%1000000007
      s=(q*pow(c,1000000005,1000000007))%1000000007
      y=(y+(s*(l1[j]%1000000007))%1000000007)%1000000007
      #print(y,s,l1[j])
     print(y)'''
  



def mult(r,v):
 w=r
 for k in range(1,v):
  w=(w*((k+r)%1000000007))%1000000007
 return w
T=int(input())
for i in range(T):
 n,x,m=list(map(int,input().split()))
 l1=[int(i) for i in input().split()]
 if x==1:
  l1[0]=l1[0]%1000000007
  print(l1[0])
 elif x==2:
  m=m%1000000007
  l1[0]=l1[0]%1000000007
  l1[1]=(l1[1]%1000000007+l1[0]*m%1000000007)%1000000007
  print(l1[1])
 else:
  m=m%1000000007
  c=0
  y=0
  y=(l1[x-1]%1000000007)
  for j in range(x-2,-1,-1):
   c=c+1
   s=(mult(m,c)*pow(c,1000000005,1000000007))%1000000007
   y=(y+(s*(l1[j]%1000000007))%1000000007)%1000000007
   #print(y,s,l1[j])
  print(y)
  



T=int(input())
for i in range(T):
 n,x,m=list(map(int,input().split()))
 l1=[int(i) for i in input().split()]
 if x==1:
  l1[0]=l1[0]%1000000007
  print(l1[0])
 elif x==2:
  m=m%1000000007
  l1[0]=l1[0]%1000000007
  l1[1]=(l1[1]%1000000007+l1[0]*m%1000000007)%1000000007
  print(l1[1])


T=int(input())
for k in range(T):
 n,x,m=list(map(int,input().split()))
 l1=[int(i) for i in input().split()]
 l2,l3=[],[]
 for i in range(len(l1)):
  l2.append(0)
  l3.append(0)
 l2[0]=l1[0]%1000000007
 for i in range(1,len(l1)):
  l2[i]=((l1[i]%1000000007)+(l2[i-1]%1000000007))%1000000007
 if m==1:
  print(l1[x-1]%1000000007)
 elif m==2:
  print(l2[x-1])
 else:
  l3[0]=l2[0]
  l3[1]=(l1[1]+((m)*l1[0])%1000000007)%1000000007
  #print(l3[1],x,l2[1])
  s=0
  v=0
  for i in range(2,x):
   s=l2[i-1]*(l2[i-1]-1)//2
   # print(l2[i-1],s)
   v=l3[i-1]*(l3[i-1]+1)//2
   #print(l3[i-1],v)
   #print(v-s)
   l3[i]=((v-s)%1000000007+l1[i])%1000000007
 print(l3[x-1])
  
  
 


T=int(input())
for k in range(T):
 n,x,m=list(map(int,input().split()))
 l1=[int(i) for i in input().split()]
 l2,l3=[],[]
 for i in range(len(l1)):
  l2.append(0)
  l3.append(0)
 l2[0]=l1[0]%1000000007
 for i in range(1,len(l1)):
  l2[i]=((l1[i]%1000000007)+(l2[i-1]%1000000007))%1000000007
 if m==1:
  print(l1[x-1]%1000000007)
 elif m==2:
  print(l2[x-1])
 else:
  l3[0]=l2[0]
  l3[1]=(l1[1]+((m)*l1[0])%1000000007)%1000000007
  #print(l3[1],x,l2[1])
  s=0
  v=0
  for i in range(2,x):
   s=l2[i-1]*(l2[i-1]-1)//2
   # print(l2[i-1],s)
   v=l3[i-1]*(l3[i-1]+1)//2
   #print(l3[i-1],v)
   #print(v-s)
   l3[i]=((v-s)%1000000007+l1[i])%1000000007
 print(l3[x-1])
  
  
 


T=int(input())
for k in range(T):
 n,x,m=list(map(int,input().split()))
 l1=[int(i) for i in input().split()]
 l2,l3=[],[]
 for i in range(len(l1)):
  l2.append(0)
  l3.append(0)
 l2[0]=l1[0]%1000000007
 for i in range(1,len(l1)):
  l2[i]=((l2[i]%1000000007)+(l2[i-1]%1000000007))%1000000007
 if m==1:
  print(l1[x-1]%1000000007)
 elif m==2:
  print(l2[x-1])
 else:
  l3[0]=l2[0]
  l3[1]=(l1[1]+((m)*l1[0])%1000000007)%1000000007
  s=0
  v=0
  for i in range(2,x):
   s=l2[i-1]*(l2[i-1]-1)//2
   v=l3[i-1]*(l3[i-1]+1)//2
   l3[i]=(v-s)%1000000007
 print(l3[x-1])
  
  
 


for _ in range(int(input())):
 n,x,m=list(map(int,input().split()))
 l=[int(i) for i in input().split()]
 MOD=10**9+7
 if x<=2:
  if x==1:
   print(l[0]%MOD)
  else:
   print((l[0]*m+l[1])%MOD)
  continue 

 temp=l[:]
 while m:
  for i in range(1,n):
   l[i]=l[i]+l[i-1]
  #l=temp[:]
  #print(l)
  m-=1 
 print(l[x-1]%MOD)
 


for _ in range(int(input())):
 n,x,m=list(map(int,input().split()))
 l=[int(i) for i in input().split()]
 MOD=10**9+7 
 temp=l[:]
 while m:
  for i in range(1,n):
   l[i]=l[i]+l[i-1]
  #l=temp[:]
  #print(l)
  m-=1 
 print(l[x-1]%MOD)


# cook your dish here
for _ in range(int(input())):
 n,x,m=list(map(int,input().split()))
 l=list(map(int,input().split()))
 q=[]
 for j in range(m):
  for i in range(1,len(l)):
   l[i]=l[i]+l[i-1]
 print(l[x-1]%(10**9 +7))


'''input
2
3 2 3
1 2 3
3 3 3 
1 2 3
'''
mod=10**9+7
for _ in range(int(input())):
 n,x,m=map(int,input().split())
 a=[int(i) for(i) in input().split()]
 ans=a[x-1]%mod
 f=1
 for i in range(1,x):
  f=f*(m-1+i)
  f=f//i
  f=f%mod;
  ans+=(a[x-1-i]*f)%mod
 print(ans%mod)

'''input
2
3 2 3
1 2 3
3 3 3 
1 2 3
'''
for _ in range(int(input())):
 n,x,m=map(int,input().split())
 a=[int(i) for(i) in input().split()]
 ans=a[x-1]
 f=1
 for i in range(1,x):
  f=f*(m-1+i)
  f=f//i
  ans+=a[x-1-i]*f
 print(ans%(10**9+7))