#include <algorithm>
#include <iostream>
#include <limits>
#include <vector>
using namespace std;
int main() {
  int w, n;
  cin >> w >> n;
  vector<int> a(n), b(n), x(w);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    cin.ignore(numeric_limits<unsigned>::max(), ',');
    cin >> b[i];
  }
  for (int i = 0; i < w; i++)
    x[i] = i + 1;
  for (int i = 0; i < n; i++)
    swap(x[a[i] - 1], x[b[i] - 1]);
  for (int i = 0; i < w; i++)
    cout << x[i] << endl;
}