#include using namespace std; int main() { bool cup[3] = {false, false, false}; int n, m; cin >> n; cup[n-1] = true; cin >> m; for (int i = 0; i < m; i++) { int tmp, tmpl, tmpr; cin >> tmpl; cin >> tmpr; tmp = cup[tmpl-1]; cup[tmpl-1] = cup[tmpr-1]; cup[tmpr-1] = tmp; } for (int i = 0; i < 3; i++) { if (cup[i] == true) { cout << i+1; return 0; } } return 0; }