#include <bits/stdc++.h>
using namespace std;

int main(){
  int w, n;
  cin >> w >> n;
  vector<int> a;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    a.push_back(s.at(0) - '0');
    a.push_back(s.at(2) - '0');
  }
  vector<int> ans(w);
  for (int i = 1; i <= w; i++) {
    int tmp = i;
    for (int j = 0; j < a.size(); j += 2) {
      if (tmp == a.at(j)) {
        tmp = a.at(j + 1);
        continue;
      }
      if (tmp == a.at(j + 1)) {
        tmp = a.at(j);
        continue;
      }
    }
    ans.at(tmp - 1) = i;
  }
  for (int i = 0; i < w; i++) {
    cout << ans.at(i) << endl;
  }
}

