#include <iostream>
using namespace std;
int main(void)
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int input = 0;
cin >> input;
int cups[4] = {0, 1,2,3 };
int ball = 1;
for (int i = 0; i < input; ++i)
{
int a, b;
cin >> a >> b;
if (a == ball && b != ball)
{
ball = cups[b];
}
else if (a != ball && b == ball)
{
ball = cups[a];
}
}
cout << ball;
return 0;
}
코딩 테스트