#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>

using namespace std;
vector<string> split(string s, char del = ' '){
  vector<string> res;
  replace(s.begin(),s.end(),del,' ');
  stringstream ss(s);
  string elem;
  for(int i=0; ss >> elem; i++){
    res.push_back(elem);
  }
  return res;
}

int main(){
  int vl, hl;
  string s;

  cin >> vl;
  cin >> hl;

  int lines[vl];
  for(int i=0; i<vl; i++){
    lines[i] = i+1;
  }

  int a, b, k;
  cin.ignore();
  for(int j=0; j<hl; j++){
    getline(cin,s);
    vector<string> str = split(s,',');
    a = atoi(str[0].c_str());
    b = atoi(str[1].c_str());

    k = lines[a-1];
    lines[a-1] = lines[b-1];
    lines[b-1] = k;
  }

  for(int m=0; m<vl; m++){
    cout << lines[m] << endl;
  }
}