#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
void solve() {
  long long n, a = 0, b = 0, c = 0, d = 0;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    string s;
    cin >> s;
    if (s == "AC") a++;
    if (s == "WA") b++;
    if (s == "TLE") c++;
    if (s == "RE") d++;
  }
  cout << "AC x " << a << '\n';
  cout << "WA x " << b << '\n';
  cout << "TLE x " << c << '\n';
  cout << "RE x " << d << '\n';
  return;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
