#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <istream>
#include <iomanip>
 
#define INPUT_FROM_FILE (0)
#if INPUT_FROM_FILE
#include <fstream>
#endif


int main(int argc, char **argv){
	int w = 0;
	int n = 0;
	int a = 0;
	int b = 0;
	char tmp = 0;
	std::vector<int> z;
#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
#endif

#if INPUT_FROM_FILE
	ifs >> w >> n;
#else
	std::cin >> w >> n;
#endif

	z.resize(w);
	for(int i = 0; i < w; i++){
		z[i] = i + 1;
	}
	for(int i = 0; i < n; i++){
#if INPUT_FROM_FILE
		ifs >> a >> tmp >> b;
#else
		std::cin >> a >> tmp >>  b;
#endif
		std::swap(z[a - 1], z[b - 1]);
	}
	for(int i = 0; i < w; i++){
		std::cout << z[i] << std::endl;
	}
	return 0;
}
