OJ-Problems-Source/HDOJ/1259_autoAC.cpp

22 lines
392 B
C++
Raw Normal View History

2016-08-13 17:16:08 +08:00
#include <stdio.h>
int main()
{
int n,i,t1,t2;
scanf("%d",&n);
while(n--)
{
int sum=2;
int m;
scanf("%d",&m);
for(i=1;i<=m;i++)
{
scanf("%d%d",&t1,&t2);
if(t2==sum)
sum=t1;
else if(t1==sum)
sum=t2;
}
printf("%d\n",sum);
}
}