#include<iostream>
#include<cstdio>

using namespace std;

#define rep(i, n) for (int i = 0; i < int(n); ++i)

int main() {
  int w, n, a[40][2], pos[40];
  cin >> w >> n;
  rep (i, n) scanf("%d,%d", a[i], a[i] + 1);
  rep (i, n) --a[i][0], --a[i][1];
  rep (i, w) pos[i] = i;
  rep (i, n) swap(pos[a[i][0]], pos[a[i][1]]);
  rep (i, w) cout << pos[i] + 1 << endl;
  return 0;
}