#include<iostream>
using namespace std;
int main(){
  int w,n;
  int p;
  cin >> w >> n;
  int c[w];
  int a[n];
  int b[n];
  int j = 0;
  int j2 = 0;
  char q[n];
  for(int i=0;i<w;i++) c[i] = i + 1;
  for(int i=0;i<n;i++){
    cin >> a[i] >> q[n] >> b[i];  
  } 
 for(int i=0;i<n;i++){
    j = a[i] - 1;
    j2 = b[i] - 1; 
    p = c[j];
    c[j] = c[j2];
    c[j2] = p;
  }  
  for(int i=0;i<w;i++) cout << c[i] << endl; 
  return 0;
}