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

int main(){

  int w;
  int n;
  int i;
  int a;
  int b;
  int number[32] = {};

  scanf("%d", &w);
  scanf("%d", &n);

  for(i = 1; i <= w; i++){
    number[i] = i;
  }

  for(i = 0; i < n; i++){
    scanf("%d,%d", &a, &b);
    swap(number[a], number[b]);
  }
  for(i = 1; i <= w; i++){
    cout<<number[i]<<endl;
  }


  return 0;
}