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

int main(){

  int n,m,x,y;

  vector <int> a;

  cin >> n;

  for(int i=0;i<=n;i++){
    a.push_back(i);
    a[i]=i;
  }

  cin >> m;
  for(int i=0;i<m;i++){
    scanf("%d,%d",&x,&y);
    swap(a[x],a[y]);
  }

  for(int i=1;i<=n;i++) cout << a[i] << endl;
}