#include <bits/stdc++.h>
//#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
typedef long long ll;

using namespace std;


signed main() {
	int n, m; cin >> n >> m;
	vector<int> v(n);
	rep(i, n) v[i] = i + 1;
	rep(i, m) {
		string s; cin >> s;
		string s1, s2;
		bool flag = true;
		for (auto a : s) {
			if (a == ',') flag = !flag;
			else if (flag) {
				s1 = s1 + a;
			}
			else {
				s2 = s2 + a;
			}
		}
		int a, b;
		a = stoi(s1);
		b = stoi(s2);
		swap(v[a - 1], v[b - 1]);
	}
	for (auto a : v) {
		cout << a << endl;
	}
}
