#include <iostream>
#include <fstream>
#include <string>
#include <vector>

using namespace std;

struct Horizontal {
	int pointA;
	int pointB;
};

inline static Horizontal perse_linecomb(string comb);

inline static Horizontal perse_linecomb(string comb) {
	Horizontal horizon;
	int canma_point = comb.find(",");

	horizon.pointA = stoi(comb.substr(0,canma_point));
	horizon.pointB = stoi(comb.substr(canma_point + 1));

	return horizon;
}

int main(void) {
	int vertical_num;
	int horizontal_num;

// enter number of vertical line
	// cout << "enter vertical line number:";
	cin >> vertical_num;
	vector<int> line(vertical_num);
	for(int i = 0; i < vertical_num; i++) {
		line.at(i) = i + 1;
	}

// enter number of horizontal line
	// cout << "enter horizontal line number:";
	cin >> horizontal_num;

//
	vector<Horizontal> horizontal_line(horizontal_num);
	// cout << "enter " << horizontal_num << " points" << endl;
	for(int i = 0; i < horizontal_num; i++) {
		string comb;
		// cout << i + 1 << " line: ";
		cin >> comb;
		horizontal_line.at(i) = perse_linecomb(comb);
	}

	for(const Horizontal &x : horizontal_line) {
		int temp;
		temp = line.at(x.pointA - 1);
		line.at(x.pointA - 1) = line.at(x.pointB - 1);
		line.at(x.pointB - 1) = temp;
	}

// print console
	for(int i = 0; i < vertical_num; i++) {
		cout << line.at(i) << endl;
	}

}

