#include using namespace std; int main(void) { int n, m; cin >> n >> m; bool a[3] = {}; a[n - 1] = true; for (int i = 0; i < m; i++) { int p, q; cin >> p >> q; swap(a[p - 1], a[q - 1]); } for (int i = 0; i < 3; i++) { if (!a[i]) continue; cout << i + 1 << endl; } return 0; }