#include <iostream>
using namespace std;
int main(){
  int w,n;
  cin >> w >> n;
  int d[w+1];
  for(int i = 1 ; i <= w ; i++ )d[i] = i;
  for(int i = 1 ; i <= n ; i++ ){
    int a,b;
    char c;
    cin >> a >> c >> b;
    swap(d[a],d[b]);
  }
  for(int i = 1 ; i <= w ; i++ )cout << d[i] << endl;
}