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

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

