Chef and Super Array

All submissions for this problem are available.
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
Chef has a an array A consisting of N elements. He wants to add some elements into the array as per the below mentioned process.
After each minute, Chef iterates over the array in order from left to right, and takes every two neighbouring pair of elements, say x and y, he adds a new element x + y in the middle of elements x and y.
For example, if initial array A = {1, 6, 9}.
 After first minute, the array A will be equal to {1, 7, 6, 15, 9}. Please note that the elements shown in the bold font are the newly added elements during first minute. As you can observe that 7 = 1 + 6, and 15 = 6 + 9.
 After second minute, the array will be {1, 8, 7, 13, 6, 21, 15, 24, 9}. Once again, elements added during the second minute, are shown in bold.
Chef wants to know the sum of elements between x^{th} and y^{th} positions in the array A (i.e. A_{x} + A_{x + 1} + ... + A_{y}) after m minutes. As the answer could be large, output it modulo 10^{9}+7 (1000000007). Please note that we use 1 based indexing in the problem.
Input
 The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.
 The first line of each test case contains four spaceseparated integers N, m, x, y denoting the number of elements in the array A in the beginning, amount of minutes and range for finding sum.
 The second line contains N spaceseparated integers A_{1}, A_{2}, ..., A_{N} denoting the array A in the beginning.
Output
 For each test case, output a single line containing an integer corresponding to the sum of elements between x^{th} and y^{th} positions in the array A after m minutes modulo 10^{9}+7.
Constraints
 1 ≤ T ≤ 10
 1 ≤ N ≤ 10^{5}
 1 ≤ A_{i} ≤ 10^{3}
 1 ≤ m ≤ 30
 1 ≤ x ≤ y ≤ size of the array A (A) after m minutes
Example
Input: 2 3 1 1 5 1 6 9 3 2 6 7 1 6 9 Output: 38 36
Explanation
Example case 1. After the first minute A = {1, 7, 6, 15, 9} and sum of all elements will be 38.
Example case 2. After the second minute the array A will be {1, 8, 7, 13, 6, 21, 15, 24, 9} and sum of elements between 6^{th} and 7^{th} equals to 21 + 15 = 36.
Author:  antoniuk1 
Tester:  
Editorial  http://discuss.codechef.com/problems/CHSPARR 
Tags  algebra, antoniuk1, medium, series, snckpa16 
Date Added:  21072015 
Time Limit:  1 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.5, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 