#include <iostream>
#include <vector>
#include <cstdio>

using namespace std;
void swap_my(int &a,int &b){
  int keep = a;
  a = b;
  b = keep;
  
}
int main(){
  int w,n;
  cin >> w >> n;
  vector<int> status(w,0);
  for(int i = 0;i < w;i++){
	status[i] = i;
  }
  for(int i = 0;i < n;i++){
	int a,b;
	scanf("%d,%d",&a,&b);
	swap_my(status[a-1],status[b-1]);
  }
  for(int i = 0;i < w;i++){
	cout << status[i]+1 << endl;
  }
  return 0;
}