#include //cin, cout #include //vector #include //sort,min,max,count #include //string,getline, to_string #include //abs(int) #include //swap, pair #include //deque #include //INT_MAX #include //bitset using namespace std; int main() { vector A(4); int N; cin >> N; A[N]++; int M; cin >> M; for (int i = 0; i < M; i++) { int p, q; cin >> p >> q; swap(A[p], A[q]); } for (int i = 1; i < 4; i++) { if (A[i] == 1) { cout << i << endl; break; } } return 0; }