#include <string>
#include <iostream>
#include <map>
using namespace std;
int main() {
string str1, str2;
int t, m;
cin>>t;
while(t--){
map<string, int> _map;
cin>>m;
while(m--){
cin>>str1>>str2;
_map[str2]++;
}
int ans = 1;
for(auto iter : _map){
ans*=(iter.second+1);
}
cout<<--ans<<endl;
}
}
map에서 탐색을 할 때는 auto를 사용하면 편리하다.
2개의 선글라스 3개의 상의가 있다고 가정하면 선글라스가 0, 1, 2번
상의가 0, 1, 2, 3번 이런식으로 종류가 나뉜다고 생각하면
총 3 * 4 = 12의 조합이 나오고 알몸인 경우인 {0, 0}인 경우를 빼면
12-1 = 11개가 나온다.