#include <iostream>
#include <stdlib.h>
#include <string>
#include <strstream>

using namespace std;

int main(int argc, char **argv)
{
	int n, w;
	int *goal, **line;
	string str, st1, st2;
	
	cin >> w;
	cin >> n;
	
	goal = (int *)calloc(w, sizeof(int));
	line = (int **)calloc(n, sizeof(int));
	for(int i = 0; i < n; i++){
		line[i] = (int *)calloc(2, sizeof(int));
		cin >> str;
		st1 = str[0];
		st2 = str[2];
		istrstream istr1(st1.data());
		istrstream istr2(st2.data());
		istr1 >> line[i][0];
		istr2 >> line[i][1];
	}
	
	for(int i = 1, tmp = 0; i <= w; i++){
		tmp = i;
		for(int j = 0; j < n; j++){
			if(tmp == line[j][0]){
				tmp = line[j][1];
			} else if(tmp == line[j][1]){
				tmp = line[j][0];
			}
		}
		goal[tmp-1] = i;
	}
	
	for(int i = 0; i < w; i++){
		cout << goal[i] << endl;
	}
	
	free(goal);
	for(int i = 0; i < n; i++){
		free(line[i]);
	}
	free(line);
	
	return 0;
}