#include using namespace std; int main(){ int N; cin >> N; vector c(3, 0); c[N - 1] = 1; int M; cin >> M; for (int i = 0; i < M; i++){ int P, Q; cin >> P >> Q; P--; Q--; swap(c[P], c[Q]); } if (c[0] == 1){ cout << 1 << endl; } if (c[1] == 1){ cout << 2 << endl; } if (c[2] == 1){ cout << 3 << endl; } }