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

int main() {
  int w, n;
  cin >> w >> n;
  vector<int> a(n), b(n);
  char c;
  for (int i = 0; i < n; ++i)
    cin >> a[i] >> c >> b[i];

  vector<int> ans(w + 1);
  for (int j = 1; j <= w; ++j)
    ans[j] = j;

  for (int i = 0; i < n; ++i)
    swap(ans[a[i]], ans[b[i]]);

  for (int j = 1; j <= w; ++j)
    cout << ans[j] << endl;
}
