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]);
		}
	}
} import java.util.Scanner; Scanner java.util 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]);
		}
	}
} Main static Scanner sc = new Scanner(System.in); 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]);
		}
	} main {
		//?????°??????
		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]);
		}
	} int vertical = sc.nextInt(); vertical sc.nextInt() sc.nextInt sc String[][] cross = new String[sc.nextInt()][2]; cross new String[sc.nextInt()][2] sc.nextInt() sc.nextInt sc 2 String[] ans = new String[vertical]; ans new String[vertical] vertical for(int count = 0; count < cross.length; count++) { //?¨?????????°????????°?????????
			cross[count] = sc.next().split(",");
		} int count = 0; int count = 0; count 0 count < cross.length count cross.length cross cross.length count++ count++ count { //?¨?????????°????????°?????????
			cross[count] = sc.next().split(",");
		} { //?¨?????????°????????°?????????
			cross[count] = sc.next().split(",");
		} cross[count] = sc.next().split(",") cross[count] cross count sc.next().split(",") sc.next().split sc.next() sc.next sc "," 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);
		} int count = 0; int count = 0; count 0 count < vertical count vertical count++ count++ 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);
		} { //???????????¬??°??¶?????°?????????
			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);
		} String dog = Integer.toString(count + 1); dog Integer.toString(count + 1) Integer.toString Integer count + 1 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 con = 0; int con = 0; con 0 con < cross.length con cross.length cross cross.length con++ con++ con { //?¨?????????¬??°??¶?????°?????????
				if(dog.equals(cross[con][0])) { //?¨?????????????????????¨???????????£???????????¨???
					//??\????????????
					dog = cross[con][1];
				} else if(dog.equals(cross[con][1])) { //?¨?????????????????????¨???????????£???????????¨???
					//??\????????????
					dog = cross[con][0];
				}
			} { //?¨?????????¬??°??¶?????°?????????
				if(dog.equals(cross[con][0])) { //?¨?????????????????????¨???????????£???????????¨???
					//??\????????????
					dog = cross[con][1];
				} else if(dog.equals(cross[con][1])) { //?¨?????????????????????¨???????????£???????????¨???
					//??\????????????
					dog = cross[con][0];
				}
			} if(dog.equals(cross[con][0])) { //?¨?????????????????????¨???????????£???????????¨???
					//??\????????????
					dog = cross[con][1];
				} else if(dog.equals(cross[con][1])) { //?¨?????????????????????¨???????????£???????????¨???
					//??\????????????
					dog = cross[con][0];
				} dog.equals(cross[con][0]) dog.equals dog cross[con][0] cross[con] cross con 0 { //?¨?????????????????????¨???????????£???????????¨???
					//??\????????????
					dog = cross[con][1];
				} dog = cross[con][1] dog cross[con][1] cross[con] cross con 1 if(dog.equals(cross[con][1])) { //?¨?????????????????????¨???????????£???????????¨???
					//??\????????????
					dog = cross[con][0];
				} dog.equals(cross[con][1]) dog.equals dog cross[con][1] cross[con] cross con 1 { //?¨?????????????????????¨???????????£???????????¨???
					//??\????????????
					dog = cross[con][0];
				} dog = cross[con][0] dog cross[con][0] cross[con] cross con 0 int num = Integer.parseInt(dog) - 1; num Integer.parseInt(dog) - 1 Integer.parseInt(dog) Integer.parseInt Integer dog 1 ans[num] = Integer.toString(count + 1) ans[num] ans num Integer.toString(count + 1) Integer.toString Integer count + 1 count 1 for(int count = 0; count < ans.length; count++) {
			System.out.println(ans[count]);
		} int count = 0; int count = 0; count 0 count < ans.length count ans.length ans ans.length count++ count++ count {
			System.out.println(ans[count]);
		} {
			System.out.println(ans[count]);
		} System.out.println(ans[count]) System.out.println System.out System System.out ans[count] ans count String[] args args 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]);
		}
	}
} 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]);
		}
	}
} Main
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]);
		}
	}
}