#include #include #include using namespace std; int main() { int N, M; vector cup(4, false); cin >> N; cup[N] = true; bool tmp; cin >> M; int p, q; for( int i = 0; i < M; i++ ) { cin >> p >> q; tmp = cup[p]; cup[p] = cup[q]; cup[q] = tmp; } for( int i = 1; i <= 3; i++ ) { if( cup[i] == true ) { cout << i << endl; return 0; } } return 0; }