#include <algorithm>
#include <sstream>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <stack>
#include <stdio.h>
#include <string>
#include <queue>
#include <vector>
using namespace std;

int main()
{
	int w, n, a, b;
	vector<int> A;

	cin >> w >> n;

	for (int i = 1; i <= w; i++) A.push_back(i);

	for (int i = 0; i < n; i++) {
		scanf("%d,%d", &a, &b);
		swap(A[a - 1], A[b - 1]);
	}

	for (int i = 0; i < w; i++) cout << A[i] << endl;
}

