#include #define rep(i,n) for(int i=0;i=0;i--) #define FOR(i,m,n) for(int i=m;i inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } //const ll INF = 1LL << 60; //const int INF = 1001001001; int main(void){ vector a(4); rep(i,4)a[i]=0; int n,m; cin >> n >> m; a[n]=1; rep(i,m){ int x,y; cin >> x >> y; swap(a[x],a[y]); } rep(i,4) if(a[i]==1)cout << i << endl; return 0; }