#include <iostream>

void swap(int*, int, int);
void sepTwoNumbers(char*, int&, int&);
int char2Number(char*, int, int);

const int MAX_VIRTICAL_LINE = 30;
const int MAX_HORIZONTAL_LINE = 30;

int main(){
	int numOfVirticalLine;
	int numOfHorizontalLine;
	int amidaList[MAX_VIRTICAL_LINE] = {};

	for (int i = 0; i < MAX_VIRTICAL_LINE; i++)
	{
		amidaList[i] = i + 1;
	}

	std::cin >> numOfVirticalLine >> numOfHorizontalLine;
	for (int i = 0; i < numOfHorizontalLine; i++)
	{
		int line1, line2;
		char swapLineInfo[6];
		std::cin >> swapLineInfo;
		sepTwoNumbers(swapLineInfo, line1, line2);
		swap(amidaList, line1, line2);
	}
	for (int i = 0; i < numOfVirticalLine; i++)
	{
		std::cout << amidaList[i] << std::endl;
	}
	return 0;
}

void sepTwoNumbers(char* charOftwoNumber, int& number1, int& number2){
	int commaIndex;
	int endIndex;
	for (commaIndex = 0; charOftwoNumber[commaIndex] != ','; ++commaIndex);
	number1 = char2Number(charOftwoNumber, 0, commaIndex);
	for (endIndex = commaIndex; charOftwoNumber[endIndex] != '\0'; ++endIndex);
	number2 = char2Number(charOftwoNumber, commaIndex + 1, endIndex);
}

int char2Number(char* charNumber, int startDigit, int endDigit){
	int number = 0;
	for (int i = startDigit; i < endDigit; ++i){
		number *= 10;
		number += charNumber[i] - '0';
	}
	return number;
}

void swap(int* amidaList, int line1, int line2){
	int temp = amidaList[line1 - 1];
	amidaList[line1 - 1] = amidaList[line2 - 1];
	amidaList[line2 - 1] = temp;
}
