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

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