// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#define dibs reserve
#define OVER9000 1234567890
#define patkan 9
#define tisic 47
#define soclose 10e-7
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define chocolate win
#define ff first
#define ss second
// mylittlepony
using namespace std;
struct node {
int st,end;
int son[2];
long long live,mod,val;};
struct intervalac {
vector<node> T;
void constI(int akt) {
node n =T[akt];
if(n.st == n.end-1) return;
for(int i =0; i < 2; i++) {
if(i == 0) n.end =(n.st+n.end)/2;
else {n.st =n.end; n.end =T[akt].end;}
T[akt].son[i] =T.size();
T.push_back(n);
constI(T[akt].son[i]);}
}
intervalac(int N) {
node n;
n.st =n.live =n.mod =n.val =0, n.end =N;
n.son[0] =n.son[1] =-1;
T.resize(1,n);
constI(0);}
void darkmagic(int akt) {
T[akt].val +=T[akt].mod*T[akt].live;
if(T[akt].son[0] != -1) for(int i =0; i < 2; i++)
T[T[akt].son[i]].mod +=T[akt].mod;
T[akt].mod =0;}
void upd1(int akt, int pos) {
node n =T[akt];
if(n.st > pos || n.end <= pos) return;
darkmagic(akt);
T[akt].live++;
if(n.son[0] != -1) {
T[akt].val =0;
for(int i =0; i < 2; i++) {
upd1(n.son[i],pos);
T[akt].val +=get(n.son[i],T[n.son[i]].st,T[n.son[i]].end);}}
}
void upd2(int akt, int st, int end, long long val) {
node n =T[akt];
if(n.st >= end || n.end <= st) return;
if(n.st == st && n.end == end) {
T[akt].mod +=val;
darkmagic(akt);
return;}
darkmagic(akt);
T[akt].val =0;
for(int i =0; i < 2; i++) {
upd2(n.son[i],max(T[n.son[i]].st,st),min(T[n.son[i]].end,end),val);
T[akt].val +=T[n.son[i]].val;}
}
long long get(int akt, int st, int end) {
node n =T[akt];
if(n.st >= end || n.end <= st) return 0;
darkmagic(akt);
if(n.st == st && n.end == end) return T[akt].val;
return get(n.son[0],st,min(end,(n.st+n.end)/2))+get(n.son[1],max(st,(n.st+n.end)/2),end);
}
};
struct fin {
vector<long long> T;
fin(int N) {T.resize(N+1,0);}
int lastone(int x) {return x&(x^(x-1));}
void upd(int pos, long long val) {
for(int i =pos+1; i < T.size(); i +=lastone(i)) T[i] +=val;}
long long get(int pos) {
long long ret =0;
for(int i =pos+1; i > 0; i -=lastone(i)) ret +=T[i];
return ret;}
};
struct info {
int r,t,id;
bool operator<(const info &A) const {
if(r != A.r) return r < A.r;
return t < A.t;}
};
long long GCD(long long a, long long b) {
if(a > b) swap(a,b);
if(a == 0) return b;
return GCD(b%a,a);}
int main() {
int T,N;
cin >> T;
for(int t =0; t < T; t++) {
cin >> N;
vector< pair<int,string> > A0(N);
map<string,int> Mt;
map<int,int> Mr;
for(int i =0; i < N; i++) {
cin >> A0[i].ss >> A0[i].ff;
Mt[A0[i].ss] =0;
Mr[-A0[i].ff] =0;}
int a =0;
ALL_THE(Mr,it) {it->ss =a; a++;}
a =0;
ALL_THE(Mt,it) {it->ss =a; a++;}
vector<info> A(N);
for(int i =0; i < N; i++) {
A[i].r =Mr[-A0[i].ff];
A[i].t =Mt[A0[i].ss];
A[i].id =i;}
sort(A.begin(),A.end());
vector<long long> Ti(N,0);
// newbie
fin Kn(N+patkan);
fin Sn(N+patkan);
for(int i =N-1; i >= 0; i--) {
long long K =Kn.get(A[i].t-1);
Ti[A[i].id] =K*(K-1)/2-Sn.get(A[i].t-1);
Sn.upd(A[i].t,Kn.get(A[i].t));
Kn.upd(A[i].t,1);}
for(int i =0; i < N; i++) A[i].t =a-1-A[i].t;
for(int k =0; k < 2; k++) {
for(int i =0; i < N; i++) swap(A[i].t,A[i].r);
sort(A.begin(),A.end());
// wild or experienced
fin Ko(N+patkan);
fin So(N+patkan);
intervalac I(N+patkan);
vector<long long> K(N);
for(int i =0; i < N; i++) {
K[i] =Ko.get(A[i].t-1);
long long S =So.get(N+1)-So.get(A[i].t);
long long X =I.get(0,A[i].t,N+1);
Ti[A[i].id] +=S-X;
if(i < N-1) if(A[i].r == A[i+1].r) continue;
for(int j =i; j >= 0; j--) {
if(A[j].r != A[i].r) break;
Ko.upd(A[j].t,1);
So.upd(A[j].t,K[j]);
I.upd2(0,0,A[j].t,1);
I.upd1(0,A[j].t);}}
}
long long Tt =0;
for(int i =0; i < N; i++) {
if(Ti[i] < 0) Ti[i] *=-1;
Tt +=Ti[i];}
if(Tt == 0) cout << "Rules Should Be Changed!";
else for(int i =0; i < N; i++) {
long long d =GCD(Tt,Ti[i]*3);
if(i > 0) cout << " ";
cout << Ti[i]*3/d << "/" << Tt/d;}
cout << "\n";}
return 0;}
// look at my code
// my code is amazing
Ly8gaW9zdHJlYW0gaXMgdG9vIG1haW5zdHJlYW0KI2luY2x1ZGUgPGNzdGRpbz4KLy8gYml0Y2ggcGxlYXNlCiNpbmNsdWRlIDxpb3N0cmVhbT4KI2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPHNldD4KI2luY2x1ZGUgPG1hcD4KI2luY2x1ZGUgPHN0cmluZz4KI2luY2x1ZGUgPHF1ZXVlPgojaW5jbHVkZSA8c3RhY2s+CiNpbmNsdWRlIDxhbGdvcml0aG0+CiNkZWZpbmUgZGlicyByZXNlcnZlCiNkZWZpbmUgT1ZFUjkwMDAgMTIzNDU2Nzg5MAojZGVmaW5lIHBhdGthbiA5CiNkZWZpbmUgdGlzaWMgNDcKI2RlZmluZSBzb2Nsb3NlIDEwZS03CiNkZWZpbmUgQUxMX1RIRShDQUtFLExJRSkgZm9yKGF1dG8gTElFID1DQUtFLmJlZ2luKCk7IExJRSAhPSBDQUtFLmVuZCgpOyBMSUUrKykKI2RlZmluZSBjaG9jb2xhdGUgd2luCiNkZWZpbmUgZmYgZmlyc3QKI2RlZmluZSBzcyBzZWNvbmQKLy8gbXlsaXR0bGVwb255CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiAgICAKc3RydWN0IG5vZGUgewogICAgaW50IHN0LGVuZDsKICAgIGludCBzb25bMl07CiAgICBsb25nIGxvbmcgbGl2ZSxtb2QsdmFsO307CiAgICAKc3RydWN0IGludGVydmFsYWMgewogICAgdmVjdG9yPG5vZGU+IFQ7CiAgICAKICAgIHZvaWQgY29uc3RJKGludCBha3QpIHsKICAgICAgICBub2RlIG4gPVRbYWt0XTsKICAgICAgICBpZihuLnN0ID09IG4uZW5kLTEpIHJldHVybjsKICAgICAgICBmb3IoaW50IGkgPTA7IGkgPCAyOyBpKyspIHsKICAgICAgICAgICAgaWYoaSA9PSAwKSBuLmVuZCA9KG4uc3Qrbi5lbmQpLzI7CiAgICAgICAgICAgIGVsc2Uge24uc3QgPW4uZW5kOyBuLmVuZCA9VFtha3RdLmVuZDt9CiAgICAgICAgICAgIFRbYWt0XS5zb25baV0gPVQuc2l6ZSgpOwogICAgICAgICAgICBULnB1c2hfYmFjayhuKTsKICAgICAgICAgICAgY29uc3RJKFRbYWt0XS5zb25baV0pO30KICAgICAgICB9CiAgICAKICAgIGludGVydmFsYWMoaW50IE4pIHsKICAgICAgICBub2RlIG47CiAgICAgICAgbi5zdCA9bi5saXZlID1uLm1vZCA9bi52YWwgPTAsIG4uZW5kID1OOwogICAgICAgIG4uc29uWzBdID1uLnNvblsxXSA9LTE7CiAgICAgICAgVC5yZXNpemUoMSxuKTsKICAgICAgICBjb25zdEkoMCk7fQogICAgCiAgICB2b2lkIGRhcmttYWdpYyhpbnQgYWt0KSB7CiAgICAgICAgVFtha3RdLnZhbCArPVRbYWt0XS5tb2QqVFtha3RdLmxpdmU7CiAgICAgICAgaWYoVFtha3RdLnNvblswXSAhPSAtMSkgZm9yKGludCBpID0wOyBpIDwgMjsgaSsrKQogICAgICAgICAgICBUW1RbYWt0XS5zb25baV1dLm1vZCArPVRbYWt0XS5tb2Q7CiAgICAgICAgVFtha3RdLm1vZCA9MDt9CiAgICAKICAgIHZvaWQgdXBkMShpbnQgYWt0LCBpbnQgcG9zKSB7CiAgICAgICAgbm9kZSBuID1UW2FrdF07CiAgICAgICAgaWYobi5zdCA+IHBvcyB8fCBuLmVuZCA8PSBwb3MpIHJldHVybjsKICAgICAgICBkYXJrbWFnaWMoYWt0KTsKICAgICAgICBUW2FrdF0ubGl2ZSsrOwogICAgICAgIGlmKG4uc29uWzBdICE9IC0xKSB7CiAgICAgICAgICAgIFRbYWt0XS52YWwgPTA7CiAgICAgICAgICAgIGZvcihpbnQgaSA9MDsgaSA8IDI7IGkrKykgewogICAgICAgICAgICAgICAgdXBkMShuLnNvbltpXSxwb3MpOwogICAgICAgICAgICAgICAgVFtha3RdLnZhbCArPWdldChuLnNvbltpXSxUW24uc29uW2ldXS5zdCxUW24uc29uW2ldXS5lbmQpO319CiAgICAgICAgfQoKICAgIHZvaWQgdXBkMihpbnQgYWt0LCBpbnQgc3QsIGludCBlbmQsIGxvbmcgbG9uZyB2YWwpIHsKICAgICAgICBub2RlIG4gPVRbYWt0XTsKICAgICAgICBpZihuLnN0ID49IGVuZCB8fCBuLmVuZCA8PSBzdCkgcmV0dXJuOwogICAgICAgIGlmKG4uc3QgPT0gc3QgJiYgbi5lbmQgPT0gZW5kKSB7CiAgICAgICAgICAgIFRbYWt0XS5tb2QgKz12YWw7CiAgICAgICAgICAgIGRhcmttYWdpYyhha3QpOwogICAgICAgICAgICByZXR1cm47fQogICAgICAgIGRhcmttYWdpYyhha3QpOwogICAgICAgIFRbYWt0XS52YWwgPTA7CiAgICAgICAgZm9yKGludCBpID0wOyBpIDwgMjsgaSsrKSB7CiAgICAgICAgICAgIHVwZDIobi5zb25baV0sbWF4KFRbbi5zb25baV1dLnN0LHN0KSxtaW4oVFtuLnNvbltpXV0uZW5kLGVuZCksdmFsKTsKICAgICAgICAgICAgVFtha3RdLnZhbCArPVRbbi5zb25baV1dLnZhbDt9CiAgICAgICAgfQoKICAgIGxvbmcgbG9uZyBnZXQoaW50IGFrdCwgaW50IHN0LCBpbnQgZW5kKSB7CiAgICAgICAgbm9kZSBuID1UW2FrdF07CiAgICAgICAgaWYobi5zdCA+P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A9PSAwKSByZXR1cm4gYjsKICAgIHJldHVybiBHQ0QoYiVhLGEpO30KCmludCBtYWluKCkgewogICAgaW50IFQsTjsKICAgIGNpbiA+PiBUOwogICAgZm9yKGludCB0ID0wOyB0IDwgVDsgdCsrKSB7CiAgICAgICAgY2luID4+IE47CiAgICAgICAgdmVjdG9yPCBwYWlyPGludCxzdHJpbmc+ID4gQTAoTik7CiAgICAgICAgbWFwPHN0cmluZyxpbnQ+IE10OwogICAgICAgIG1hcDxpbnQsaW50PiBNcjsKICAgICAgICBmb3IoaW50IGkgPTA7IGkgPCBOOyBpKyspIHsKICAgICAgICAgICAgY2luID4+IEEwW2ldLnNzID4+IEEwW2ldLmZmOwogICAgICAgICAgICBNdFtBMFtpXS5zc10gPTA7CiAgICAgICAgICAgIE1yWy1BMFtpXS5mZl0gPTA7fQogICAgICAgIGludCBhID0wOwogICAgICAgIEFMTF9USEUoTXIsaXQpIHtpdC0+c3MgPWE7IGErKzt9CiAgICAgICAgYSA9MDsKICAgICAgICBBTExfVEhFKE10LGl0KSB7aXQtPnNzID1hOyBhKys7fQogICAgICAgIHZlY3RvcjxpbmZvPiBBKE4pOwogICAgICAgIGZvcihpbnQgaSA9MDsgaSA8IE47IGkrKykgewogICAgICAgICAgICBBW2ldLnIgPU1yWy1BMFtpXS5mZl07CiAgICAgICAgICAgIEFbaV0udCA9TXRbQTBbaV0uc3NdOwogICAgICAgICAgICBBW2ldLmlkID1pO30KICAgICAgICBzb3J0KEEuYmVnaW4oKSxBLmVuZCgpKTsKICAgICAgICAKICAgICAgICB2ZWN0b3I8bG9uZyBsb25nPiBUaShOLDApOwogICAgICAgIAogICAgICAgIC8vIG5ld2JpZQogICAgICAgIGZpbiBLbihOK3BhdGthbik7CiAgICAgICAgZmluIFNuKE4rcGF0a2FuKTsKICAgICAgICBmb3IoaW50IGkgPU4tMTsgaSA+PSAwOyBpLS0pIHsKICAgICAgICAgICAgbG9uZyBsb25nIEsgPUtuLmdldChBW2ldLnQtMSk7CiAgICAgICAgICAgIFRpW0FbaV0uaWRdID1LKihLLTEpLzItU24uZ2V0KEFbaV0udC0xKTsKICAgICAgICAgICAgU24udXBkKEFbaV0udCxLbi5nZXQoQVtpXS50KSk7CiAgICAgICAgICAgIEtuLnVwZChBW2ldLnQsMSk7fQogICAgICAgIAogICAgICAgIGZvcihpbnQgaSA9MDsgaSA8IE47IGkrKykgQVtpXS50ID1hLTEtQVtpXS50OwogICAgICAgIGZvcihpbnQgayA9MDsgayA8IDI7IGsrKykgewogICAgICAgICAgICBmb3IoaW50IGkgPTA7IGkgPCBOOyBpKyspIHN3YXAoQVtpXS50LEFbaV0ucik7CiAgICAgICAgICAgIHNvcnQoQS5iZWdpbigpLEEuZW5kKCkpOwogICAgICAgICAgICAvLyB3aWxkIG9yIGV4cGVyaWVuY2VkCiAgICAgICAgICAgIGZpbiBLbyhOK3BhdGthbik7CiAgICAgICAgICAgIGZpbiBTbyhOK3BhdGthbik7CiAgICAgICAgICAgIGludGVydmFsYWMgSShOK3BhdGthbik7CiAgICAgICAgICAgIHZlY3Rvcjxsb25nIGxvbmc+IEsoTik7CiAgICAgICAgICAgIAogICAgICAgICAgICBmb3IoaW50IGkgPTA7IGkgPCBOOyBpKyspIHsKICAgICAgICAgICAgICAgIEtbaV0gPUtvLmdldChBW2ldLnQtMSk7CiAgICAgICAgICAgICAgICBsb25nIGxvbmcgUyA9U28uZ2V0KE4rMSktU28uZ2V0KEFbaV0udCk7CiAgICAgICAgICAgICAgICBsb25nIGxvbmcgWCA9SS5nZXQoMCxBW2ldLnQsTisxKTsKICAgICAgICAgICAgICAgIFRpW0FbaV0uaWRdICs9Uy1YOwogICAgICAgICAgICAgICAgaWYoaSA8IE4tMSkgaWYoQVtpXS5yID09IEFbaSsxXS5yKSBjb250aW51ZTsKICAgICAgICAgICAgICAgIGZvcihpbnQgaiA9aTsgaiA+PSAwOyBqLS0pIHsKICAgICAgICAgICAgICAgCQlpZihBW2pdLnIgIT0gQVtpXS5yKSBicmVhazsKCSAgICAgICAgICAgICAgICBLby51cGQoQVtqXS50LDEpOwoJICAgICAgICAgICAgICAgIFNvLnVwZChBW2pdLnQsS1tqXSk7CgkJCQkJSS51cGQyKDAsMCxBW2pdLnQsMSk7CiAgICAgICAgICAgICAgIAkJSS51cGQxKDAsQVtqXS50KTt9fQogICAgICAgICAgICB9CiAgICAgICAgCiAgICAgICAgbG9uZyBsb25nIFR0ID0wOwogICAgICAgIGZvcihpbnQgaSA9MDsgaSA8IE47IGkrKykgewogICAgICAgIAlpZihUaVtpXSA8IDApIFRpW2ldICo9LTE7CiAgICAgICAgCVR0ICs9VGlbaV07fQogICAgICAgIGlmKFR0ID09IDApIGNvdXQgPDwgIlJ1bGVzIFNob3VsZCBCZSBDaGFuZ2VkISI7CiAgICAgICAgZWxzZSBmb3IoaW50IGkgPTA7IGkgPCBOOyBpKyspIHsKICAgICAgICAgICAgbG9uZyBsb25nIGQgPUdDRChUdCxUaVtpXSozKTsKICAgICAgICAgICAgaWYoaSA+IDApIGNvdXQgPDwgIiAiOwogICAgICAgICAgICBjb3V0IDw8IFRpW2ldKjMvZCA8PCAiLyIgPDwgVHQvZDt9CiAgICAgICAgY291dCA8PCAiXG4iO30KICAgIHJldHVybiAwO30KICAgICAgICAKLy8gbG9vayBhdCBteSBjb2RlCi8vIG15IGNvZGUgaXMgYW1hemluZw==