#include<iostream>
using namespace std;
int main()
{
int T;
scanf("%d", &T);
while(T--)
{
int n, a, b;
scanf("%d", &n);
int i, count = 2;
for( i=0; i < n; i++ )
{
scanf("%d%d", &a, &b);
if(a == count)
count = b;
else if(b == count)
count = a;
}
printf("%d\n", count);
}
return 0;
}
hdu 1259 ZJUTACM
最新推荐文章于 2019-11-28 21:18:06 发布