#include <bits/stdc++.h>
using namespace std;

int main() {
  int w, n, nx, ny;

  cin >> w >> n;
  vector<int> a(w);
  for(int i = 0; i < w; i++) a[i] = i+1;
  for(int i = 0; i < n; i++) {
    int x, y;
    scanf("%d,%d", &x, &y);
     swap(a[x-1], a[y-1]);
  }
  for(int i = 0; i < w; i++) cout << a[i] << endl;
}