#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define REP(i,n) for(int i=0; i=b; --i) #define ALL(c) (c).begin(), (c).end() typedef long long ll; typedef vector VI; typedef vector VL; typedef vector VVI; typedef pair P; typedef pair PL; int main() { int n, m; cin >> n >> m; int a[] = {0,1,2}; while (m--){ int x, y; cin >> x >> y; swap(a[x-1],a[y-1]); } REP(i,3) if (a[i] == n-1) cout << i+1 << endl; return 0; }