#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int amida[31];
  for ( int i = 0; i < 31; i++ ) amida[i] = i;
  int w,n; cin >> w >> n;
  for ( int i = 0; i < n; i++ ) {
    int a,b; char ch;
    cin >> a >> ch >> b;
    swap(amida[a],amida[b]);
  }
  for ( int i = 1; i <= w; i++ ) cout << amida[i] << endl;;
  return 0;
}