#include <iostream>

using namespace std;

struct stick {
  int a;
  int b;
};

int w, n;

int main() {
  int i;
  cin >> w;
  cin >> n;
  stick s[n];
  char split;

  for(i = 0; i < n; i++)
    cin >> s[i].a >> split >> s[i].b;

  for(i = 1; i <= w; i++) {
    int start = i;
    int j;

    for(j = n - 1; 0 <= j; j--) {
      int flag = start;
      if(start == s[j].a)
	flag = s[j].b;
      if(start == s[j].b)
	flag = s[j].a;
      start = flag;
    }
    cout << start << endl;
  }
  
  return 0;
}
