#include #define rep(i, n) for(long long i = 0; i < n; i++) #define ALL(v) (v).begin(), (v).end() using namespace std; using lint = long long; int main() { int n, m; cin >> n >> m; vector v(4, 0); v[n] = 1; while (m--) { int p, q; cin >> p >> q; swap(v[p], v[q]); } rep(i, 4) { if (v[i] == 1) { cout << i << endl; } } }