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

int main() {
  int w, n;
  cin >> w >> n;
  int ans[n];

  for (int i=0; i<=w; i++)
    ans[i] = i;
  for (int i=0; i<n; i++) {
    int a, b;
    scanf("%d,%d", &a, &b);
    swap(ans[a], ans[b]);
  }
  for (int i=1; i<=w; i++)
    cout << ans[i] << endl;
}