#include <iostream>
using namespace std;

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

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