#include<iostream>
#include<sstream>
using namespace std;
int t,m,qsum;
int child,mother;
string s;//string
struct make {
char c;
int q;
};
make l[11];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin>>t;
for(int i=0;i<t;i++){
qsum=0;
child=1;
mother=1;
cin>>m>>s;
for(int j=0;j<m;j++) {
int a;
cin>>l[j].c>>a;
l[j].q=a;
qsum+=a;
}
for(int j=0;j<s.length();j++) {
int k=0;
while(s[j]!=l[k].c) k++;
child*=l[k].q;
mother*=qsum;
l[k].q--;
qsum--;
}
if(child==1 && mother==1) cout<<"0 DD真幸運!!我要下注!\n";
if(child==0) cout<<"1\n";
else {
int maxx=1;
for(int j=2;j<=mother/2;j++)
if(child%j==0 && mother%j==0) maxx=j;
child/=maxx;
mother/=maxx;
cout<<mother-child<<"/"<<mother;
if(child*2-mother>=0) cout<<" DD真幸運!!我要下注!";
cout<<'\n';
}
}
}