#include #include #include #include #include #include using namespace std; #define diff(x, y) ((x) > (y) ? ((x) - (y)) : ((y) - (x))) int main(void) { int n, x, y; vector ans(4, false); cin >> x >> n; ans[x] = true; for (int i = 0; i < n; i++) { cin >> x >> y; swap(ans[x], ans[y]); } for (int i = 0; i < 4; i++) { if (ans[i]) cout << i << endl; } return 0; }