#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1009,MOD = 1e9 + 7,INF = 1e18;
int n,m;
int a[N];
int tmp[N],top;
int dp[N][N];
struct BinaryIndexedTree{
int t[N];
int lowbit(int x){
return x & (-x);
}
void update(int pos,int v){
for(int i = pos;i <= top;i += lowbit(i))
t[i] += v;
}
int query(int pos){
int ret = 0;
for(int i = pos;i;i -= lowbit(i))
ret += t[i];
return ret;
}
void clear(){
memset(t,0,sizeof t);
}
} BIT;
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
int t;
cin >> t;
for(int id = 1;id <= t;id++){
memset(dp,0,sizeof dp);
top = 0;
cin >> n >> m;
for(int i = 1;i <= n;i++){
cin >> a[i];
tmp[++top] = a[i];
}
a[0] = -INF;
tmp[++top] = a[0];
sort(tmp + 1,tmp + top + 1);
top = unique(tmp + 1,tmp + top + 1) - tmp - 1;
for(int i = 0;i <= n;i++)
a[i] = lower_bound(tmp + 1,tmp + top + 1,a[i]) - tmp;
dp[0][0] = 1;
for(int i = 1;i <= m;i++){
BIT.clear();
BIT.update(a[0],dp[i - 1][0]);
for(int j = 1;j <= n;j++){
dp[i][j] = BIT.query(a[j] - 1) % MOD;
BIT.update(a[j],dp[i - 1][j]);
}
}
int ans = 0;
for(int i = 1;i <= n;i++)
(ans += dp[m][i]) %= MOD;
cout << "Case #" << id << ": " << ans << '\n';
}
return 0;
}