#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

int main(){
  int N;
  cin >> N;
  bool s[3];
  s[0] = s[1] = s[2] = true;
  s[N-1] = 1;
  int M;
  cin >> M;
  FOR(i,0,M){
    int a, b;
    cin >> a >> b;
    a--;b--;
    swap(s[a], s[b]);
  }
  FOR(i,0,3){
    if(s[i]){
      cout << i + 1 << endl;
    }
  }
  return 0;
}