maxN=10**5+30
fact=[1]*maxN
inv=[1]*maxN
MOD=10**9+7

def power(a,b):
    if b==0:
        return 1
    if b%2==0:
        x=power(a,b/2)%MOD
        return (x*x)%MOD
    else:
        x=power(a,b/2)%MOD
        return (a*((x*x)%MOD))%MOD

        
t=int(raw_input())
for i in xrange(2,maxN):
    fact[i]=(fact[i-1]*i)%MOD
inv[maxN-1]=power(fact[maxN-1],MOD-2)%MOD
for i in xrange(maxN-1,0,-1):
    inv[i-1]=i*inv[i]%MOD
    


for asdgdsg in xrange(t):
    n,k=(int(e) for e in raw_input().split())
    arr=[int(e) for e in raw_input().split()]
    s=0
    arr.sort()
    for i in xrange(0,len(arr)-k+1):
        temp=n-i-1
        temp=fact[temp]
        temp=(((temp*inv[n-i-k])%MOD)*inv[k-1])%MOD
        temp=temp*arr[i]%MOD
        s+=temp
    print s%MOD