#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <queue>
#include <string>
#include <complex>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
#define repa(i,s,e) for(int i=s; i<=e; i++)
#define repd(i,s,e) for(int i=s; i>=e; i--)

typedef vector<int> vi;

int w,n,a,b;

int main() {
	scanf("%d", &w);
	vi v(w);
	rep(i,w) v[i] = i+1;

	scanf("%d", &n);
	rep(i,n) {
		scanf("%d,%d", &a, &b);
		swap(v[a-1], v[b-1]);
	}

	rep(i,w) printf("%d\n", v[i]);
}