#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll mod = 1e9+7;
int main()
{
int t;
cin>>t;
for(int i=1;i<=t;i++)
{
ll n;
cin>>n;
string s;
cin>>s;
ll res=0;
for(int j=0;j<s.size();j++)
{
ll a=j+1,b=n-j;
a*=(a+1LL);
a/=2LL;a--;
b*=(b+1LL);
b/=2LL;
a%=mod;b%=mod;
a+=b;
a%=mod;
a*=s[j];
a%=mod;
res+=a;
res%=mod;
}
printf("Case %d: %lld\n",i,res);
}
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKI2RlZmluZSBsbCBsb25nIGxvbmcKCmxsIG1vZCA9IDFlOSs3OwppbnQgbWFpbigpCnsKICAgIGludCB0OwogICAgY2luPj50OwogICAgZm9yKGludCBpPTE7aTw9dDtpKyspCiAgICB7CiAgICAgICAgbGwgbjsKICAgICAgICBjaW4+Pm47CiAgICAgICAgc3RyaW5nIHM7CiAgICAgICAgY2luPj5zOwogICAgICAgIGxsIHJlcz0wOwogICAgICAgIGZvcihpbnQgaj0wO2o8cy5zaXplKCk7aisrKQogICAgICAgIHsKICAgICAgICAgICAgbGwgYT1qKzEsYj1uLWo7CiAgICAgICAgICAgIGEqPShhKzFMTCk7CiAgICAgICAgICAgIGEvPTJMTDthLS07CiAgICAgICAgICAgIGIqPShiKzFMTCk7CiAgICAgICAgICAgIGIvPTJMTDsKICAgICAgICAgICAgYSU9bW9kO2IlPW1vZDsKICAgICAgICAgICAgYSs9YjsKICAgICAgICAgICAgYSU9bW9kOwogICAgICAgICAgICBhKj1zW2pdOwogICAgICAgICAgICBhJT1tb2Q7CiAgICAgICAgICAgIHJlcys9YTsKICAgICAgICAgICAgcmVzJT1tb2Q7CiAgICAgICAgfQogICAgICAgIHByaW50ZigiQ2FzZSAlZDogJWxsZFxuIixpLHJlcyk7CiAgICB9Cgp9Cg==