#include<bits/stdc++.h>
using namespace std;
int main()
{
int t, n, m, kp = 0, i, j;
cin >> t;
while(t--)
{
if(kp > 0)
cout << "\n";
cin >> n >> m;
map<int, char>mp;
for(i=1;i<=n;i++)
{
mp[i] = 'd';
}
int r; char ch;
for(i=1;i<=m;i++)
{
cin >> r;
int p = 2*r;
vector<int>v(p+1);
for(j=1;j<=p;j++)
cin >> v[j];
cin >> ch;
if(ch == '=')
{
for(j=1;j<=p;j++)
{
mp[v[j]] = 's';
}
}
}
int c = 0, kiss = 0;
for(i=1;i<=n;i++)
{
if(mp[i] == 'd')
{
c++;
kiss = i;
}
}
if(c == 1)
cout << kiss << "\n";
else
cout << 0 << "\n";
kp++;
}
return 0;
}
Comments
Post a Comment