#include<iostream>
#include<stdlib.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

void swap(int& x, int& y) {
  int tmp = x;
  x = y;
  y = tmp;
}

int main() {
  int w, n;
  int ws[30];
  cin >> w;
  REP(i,w-1) { ws[i] = i+1; }
  cin >> n;
  REP(i,n-1) { 
    string s;
    int a, b;
    cin>>s;
    a=atoi((s.substr(0,s.find(","))).c_str());
    b=atoi((s.substr(s.find(",")+1)).c_str());
    swap(ws[a], ws[b]);
  }
  return 0;
}