#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; long long MOD = 1000000007; int main() { int C[3] = {0}; int N,M; cin >> N >> M; C[N-1] = 1; for ( int i = 0; i < M; i++ ) { int p,q; cin >> p >> q; swap(C[p-1],C[q-1]); } for ( int i = 0; i < 3; i++ ) { if ( C[i] ) { cout << i+1 << endl; } } return 0; }