#include <iostream>
#include <algorithm>
using namespace std;

int main(void){
  int w,n,a[31],tempi,temp2;
  char temp;
  for(int i = 0; i < 31; i++){
    a[i] = i + 1;
  }
  cin >> w >> n;
  for(int i = 0; i < n; i++){
    cin >> tempi >> temp >> temp2;
    swap(a[tempi - 1],a[temp2 - 1]);
  }
  for(int i = 0; i < w; i++){
    cout << a[i] << endl;
  }
  return 0;
}
