#include <stdio.h>
#include <algorithm>
#include <iostream>
using namespace std;

#define REP(i,n) for(int i=0; i<n; i++)

int main()
{
  int w=0;
  int n=0;
  cin >> w >> n;

  int lines[w+1];
  REP(i,w+1)
    lines[i] = i;

  REP(i,n){
    int from, to;
    char del;
    cin >> from >> del >> to;
    swap(lines[from], lines[to]);
  }

  for(int i=1; i<w+1; i++)
    cout << lines[i] << endl;

  return 0;
}