#include int main(void){ int N, M; int P, Q; int i, a[3] = { 1, 2, 3}, temp; scanf ("%d%d", &N, &M); for ( i = 0; i < M; i++){ scanf ("%d%d", &P, &Q); temp = a[P - 1]; a[P - 1] = a[Q - 1]; a[Q - 1] = temp; } for ( i = 0; i < 3; i++){ if ( a[i] == N) printf ("%d", i + 1); } return 0; }