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

int main ()
{
  int w, n, a, b, c;
  int r[30];
  cin >> w >> n;
  
  for (int i = 0; i <= w; i++){
    r[i] = i + 1;
  }

  for (int i = 0; i < n; i++){
    scanf("%d,%d", &a, &b);
    c = r[a - 1];
    r[a - 1] = r[b - 1];
    r[b - 1] = c;
  }

  for (int i = 0; i < w; i++){
    cout << r[i] << endl;
  } 

  return 0;
}