import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		String strLine ="";
		BufferedReader stdReader =
				new BufferedReader(new InputStreamReader(System.in));

		int MAX_DETASET  = 100;
		int cnt = 0;

		boolean nullflug = true;
		ArrayList<Integer> lineList1 = new ArrayList<Integer>();
		ArrayList<Integer> lineList2 = new ArrayList<Integer>();
		ArrayList<Integer>	numberList = new ArrayList<Integer>();
		ArrayList<Integer> tateyokoList = new ArrayList<Integer>();

		int lineMaxTate = 100;
		int lineMaxYoko = 100;

		//1. int?????????????????\???????????????????????????

		while((strLine = stdReader.readLine()) != null) {

			String[] temp = strLine.split(",",0);

			if(cnt > lineMaxYoko){
				break;
			}else if(temp.length > 1 ){//????????????????????????
				lineList1.add(Integer.parseInt(temp[0])-1);
				lineList2.add(Integer.parseInt(temp[1])-1);

			}else{

				if(cnt == 0){
					lineMaxTate = Integer.parseInt(temp[0]);
				}else if(cnt == 1){
					lineMaxYoko = Integer.parseInt(temp[0]);

				}
				cnt++;
			}

		}





		//2. ???????????????????????¨??????????????\??£?????????????????????????????§???????????????
		//   ????§??????????numberList???????´?

		for(int j = 0; j< lineMaxTate; j++){

			int now = j;

			for(int i = lineMaxYoko - 1; i >=0 ; i--){

				if(lineList1.get(i) == now){

					now = lineList2.get(i);

				}else if (lineList2.get(i) == now){

					now = lineList1.get(i);

				}else{ //????????????

				}

			}

			numberList.add(now);
		}


		//3. ??????

		for(int i = 0; i < numberList.size(); i++){

			System.out.println(numberList.get(i)+1);

		}


	}


}
/tmp/hf-datasets-cache/medium/datasets/42704881117311-config-parquet-and-info-qiankunmu-Project_CodeNet-896c9d36/hub/datasets--qiankunmu--Project_CodeNet_Python800_and_Java250/snapshots/c899fde44a77ba1cc14973ed3de064e4ff3aadc7/Project_CodeNet_Java250.tar.gz