#include <iostream>
#include <vector>

using namespace std;

void solve(int w,int n){
  vector<int> v;
  for(int i=0;i<w+1;i++){
    v.push_back(i);
  }
  for(int i=0;i<n;i++){
    int a,b;
    char c;
    cin >> a >>c>> b;
    int temp = v[a];
    v[a] = v[b];
    v[b] = temp;
  }
  for(int i=1;i<w+1;i++){
    cout << v[i] << endl;
  }
}
int main(){
  int w,n;
  cin >> w;
  cin >> n;
  solve(w,n);
  return 0;
}