#include #include using namespace std; int main(void){ // Your code here! int position,num; cin >> position >> num; vectorv = {0,0,0}; for(int i = 0; i < 3; i++) { if((position - 1) == i)v[i] = 1; } for(int i = 0; i < num; i++) { int a,b,c; cin >> a >> b; c = v[a - 1]; v[a - 1] = v[b - 1]; v[b - 1] = c; } for(int i = 0; i < 3; i++) { if(v[i])cout << i + 1 << endl; } }