#include <bits/stdc++.h>
#define endl "\n"
#define mod 1000000007
#define ll long long int
using namespace std;

ll modin(ll a)
{
    ll x = 1LL, y = a, b=(mod-2LL);
    while(b>0)
    {
        if(b&1)
        {
            x=(x*y);
            if (x>=mod) x=x%mod;
        }
        y = (y*y);
        if (y>=mod) y=y%mod;
        b=b>>1; // b/=2
    }
    return x;
}

int main()
{
    ios::sync_with_stdio(false);
    ll t;
    cin>>t;
    ll n,x,m,temp1,ans,temp2,temp3,temp4;
    ll a[100006];
    while (t--)
    {
        ans=0;
        temp1=0;
        temp2=0;
        temp3=0;
        temp4=0;
        cin>>n>>x>>m;
        for (ll i=1LL;i<=n;i++)
        {
            cin>>a[i];
            a[i]%=mod;
        }
        if (x==1)
            cout<<(a[1]%mod)<<endl;
        else if (m==1)
        {
            for (ll i=1LL;i<=x;i++)
            {
                ans = (ans + (a[i]%mod))%mod;
            }
        }
        else
        {
            temp1 = 1LL;
            ans = ((temp1*(a[x]%mod))%mod);
            temp3 = m;
            temp4 = 1LL;
            for (ll i=1LL;i<x;i++)
            {
                temp2 = (((temp3%mod)*(modin(temp4)%mod))%mod);
                temp1 = (temp1*temp2)%mod;
                ans = ((ans+((temp1*(a[x-i]%mod))%mod))%mod);
                temp3++;
                temp4++;
            }
            cout<<(ans%mod)<<endl;
        }
    }
    return 0;
}
