#include <iostream>
#include <cstdio>

#include <cmath>

#include <vector>

using namespace std;

int main(void)
{
	int w, n;

	cin >> w;
	cin >> n;

	vector<pair<int, int>> intersection(n);

	for(int i = 0; i < n; i++){
		scanf("%d,%d", &intersection[i].first, &intersection[i].second);
	}

	for(int i = 1; i <= w; i++){
		int r = i;
		for(const auto& x : intersection){
			if(x.first == r){
				r = x.second;
				break;
			}
			if(x.second == r){
				r = x.first;
				break;
			}
		}
		cout << r << endl;
	}

	return 0;
}