#include using namespace std; #define REP(i, n) for(int i = 0; i < n; i++) int main() { ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; vector a(4); a[n] = 1; REP(i, m) { int p, q; cin >> p >> q; swap(a[p], a[q]); } REP(i, 4) if (a[i] == 1) cout << i << endl; return 0; }