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

const int MAXN = 33;
int w, n;
int a[MAXN], b[MAXN];

int main() {
  while(cin >> w) {
    cin >> n;
    for(int i = 0; i < n; ++i) {
      string s;
      cin >> s;
      replace(s.begin(), s.end(), ',', ' ');
      stringstream ss(s);
      ss >> a[i] >> b[i];
      --a[i];
      --b[i];
    }
    int res[w];
    for(int j = 0; j < w; ++j) {
      int p = j;
      for(int i = 0; i < n; ++i) {
	if(p == a[i]) {
	  p = b[i];
	} else if(p == b[i]) {
	  p = a[i];
	}
      }
      res[p] = j;
    }
    for(int j = 0; j < w; ++j) {
      cout << res[j]+1 << endl;
    }
  }
  return 0;
}