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

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

  for (int i=0; i<w; i++)
    ans[i] = i+1;
  for (int i=0; i<n; i++) {
    string s;
    cin >> s;
    int a = s[0] - '1';
    int b = s[2] - '1';
    swap(ans[a], ans[b]);
  }
  for (int i=0; i<w; i++)
    cout << ans[i] << endl;
}