import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		//?????°??????
		int vertical = sc.nextInt(); //???????????¬??°
		String[][] cross = new String[sc.nextInt()][2]; //?¨?????????¬??°
		String[] ans = new String[vertical];

		//?¨???????????´°???????????????
		for(int count = 0; count < cross.length; count++) { //?¨?????????°????????°?????????
			cross[count] = sc.next().split(",");
		}

		//???????????????
		for(int count = 0; count < vertical; count++) { //???????????¬??°??¶?????°?????????
			String dog = Integer.toString(count + 1);

			for(int con = 0; con < cross.length; con++) { //?¨?????????¬??°??¶?????°?????????
				if(dog.equals(cross[con][0])) { //?¨?????????????????????¨???????????£???????????¨???
					//??\????????????
					dog = cross[con][1];
				} else if(dog.equals(cross[con][1])) { //?¨?????????????????????¨???????????£???????????¨???
					//??\????????????
					dog = cross[con][0];
				}
			}

			int num = Integer.parseInt(dog) - 1;
			ans[num] = Integer.toString(count + 1);
		}

		//??¨?????????
		for(int count = 0; count < ans.length; count++) {
			System.out.println(ans[count]);
		}
	}
}
/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