#include <bits/stdc++.h>

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