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

int main() {
  int w, n, a, b;
  char d;
  cin >> w >> n;
  vector<int> v(w + 1);
  for (int i = 0; i <= w; i++) {
    v[i] = i;
  }
  for (int i = 0; i < n; i++) {
    cin >> a >> d >> b;
    int t = v[a];
    v[a] = v[b];
    v[b] = t;
  }
  for (int i = 1; i <= w; i++) {
    cout << v[i] << endl;
  }
  return 0;
}
