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

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int lineNum = Integer.parseInt(br.readLine());
		int changeNum = Integer.parseInt(br.readLine());

		int[][] changer = new int[changeNum+1][lineNum+1];
		//?????????
		for(int i = 1; i <= changeNum ; i++){
			for(int j = 1; j <= lineNum; j++){
				changer[i][j] = j;
			}
		}

		//??\???????????????
		for(int i = 1;i <= changeNum; i++){
			String[] tmpStr = br.readLine().split(",");
			changer[i][Integer.parseInt(tmpStr[0])] = Integer.parseInt(tmpStr[1]);
			changer[i][Integer.parseInt(tmpStr[1])] = Integer.parseInt(tmpStr[0]);
		}

		//???????????????
		int[] answer = new int[lineNum + 1];

		for(int i = 1; i <= lineNum ; i++){
			int tmpAnswer = i;

			for(int j = 1; j <= changeNum ; j++){
				//System.out.println("next "+changer[j][tmpAnswer]);
				tmpAnswer = changer[j][tmpAnswer];
			}

			answer[tmpAnswer] = i;
		}

		for(int i = 1; i <= lineNum; i++){
			System.out.println(answer[i]);
		}
	}

} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int lineNum = Integer.parseInt(br.readLine());
		int changeNum = Integer.parseInt(br.readLine());

		int[][] changer = new int[changeNum+1][lineNum+1];
		//?????????
		for(int i = 1; i <= changeNum ; i++){
			for(int j = 1; j <= lineNum; j++){
				changer[i][j] = j;
			}
		}

		//??\???????????????
		for(int i = 1;i <= changeNum; i++){
			String[] tmpStr = br.readLine().split(",");
			changer[i][Integer.parseInt(tmpStr[0])] = Integer.parseInt(tmpStr[1]);
			changer[i][Integer.parseInt(tmpStr[1])] = Integer.parseInt(tmpStr[0]);
		}

		//???????????????
		int[] answer = new int[lineNum + 1];

		for(int i = 1; i <= lineNum ; i++){
			int tmpAnswer = i;

			for(int j = 1; j <= changeNum ; j++){
				//System.out.println("next "+changer[j][tmpAnswer]);
				tmpAnswer = changer[j][tmpAnswer];
			}

			answer[tmpAnswer] = i;
		}

		for(int i = 1; i <= lineNum; i++){
			System.out.println(answer[i]);
		}
	}

} Main public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int lineNum = Integer.parseInt(br.readLine());
		int changeNum = Integer.parseInt(br.readLine());

		int[][] changer = new int[changeNum+1][lineNum+1];
		//?????????
		for(int i = 1; i <= changeNum ; i++){
			for(int j = 1; j <= lineNum; j++){
				changer[i][j] = j;
			}
		}

		//??\???????????????
		for(int i = 1;i <= changeNum; i++){
			String[] tmpStr = br.readLine().split(",");
			changer[i][Integer.parseInt(tmpStr[0])] = Integer.parseInt(tmpStr[1]);
			changer[i][Integer.parseInt(tmpStr[1])] = Integer.parseInt(tmpStr[0]);
		}

		//???????????????
		int[] answer = new int[lineNum + 1];

		for(int i = 1; i <= lineNum ; i++){
			int tmpAnswer = i;

			for(int j = 1; j <= changeNum ; j++){
				//System.out.println("next "+changer[j][tmpAnswer]);
				tmpAnswer = changer[j][tmpAnswer];
			}

			answer[tmpAnswer] = i;
		}

		for(int i = 1; i <= lineNum; i++){
			System.out.println(answer[i]);
		}
	} main {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int lineNum = Integer.parseInt(br.readLine());
		int changeNum = Integer.parseInt(br.readLine());

		int[][] changer = new int[changeNum+1][lineNum+1];
		//?????????
		for(int i = 1; i <= changeNum ; i++){
			for(int j = 1; j <= lineNum; j++){
				changer[i][j] = j;
			}
		}

		//??\???????????????
		for(int i = 1;i <= changeNum; i++){
			String[] tmpStr = br.readLine().split(",");
			changer[i][Integer.parseInt(tmpStr[0])] = Integer.parseInt(tmpStr[1]);
			changer[i][Integer.parseInt(tmpStr[1])] = Integer.parseInt(tmpStr[0]);
		}

		//???????????????
		int[] answer = new int[lineNum + 1];

		for(int i = 1; i <= lineNum ; i++){
			int tmpAnswer = i;

			for(int j = 1; j <= changeNum ; j++){
				//System.out.println("next "+changer[j][tmpAnswer]);
				tmpAnswer = changer[j][tmpAnswer];
			}

			answer[tmpAnswer] = i;
		}

		for(int i = 1; i <= lineNum; i++){
			System.out.println(answer[i]);
		}
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) int lineNum = Integer.parseInt(br.readLine()); lineNum Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br int changeNum = Integer.parseInt(br.readLine()); changeNum Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br int[][] changer = new int[changeNum+1][lineNum+1]; changer new int[changeNum+1][lineNum+1] changeNum+1 changeNum 1 lineNum+1 lineNum 1 for(int i = 1; i <= changeNum ; i++){
			for(int j = 1; j <= lineNum; j++){
				changer[i][j] = j;
			}
		} int i = 1; int i = 1; i 1 i <= changeNum i changeNum i++ i++ i {
			for(int j = 1; j <= lineNum; j++){
				changer[i][j] = j;
			}
		} {
			for(int j = 1; j <= lineNum; j++){
				changer[i][j] = j;
			}
		} for(int j = 1; j <= lineNum; j++){
				changer[i][j] = j;
			} int j = 1; int j = 1; j 1 j <= lineNum j lineNum j++ j++ j {
				changer[i][j] = j;
			} {
				changer[i][j] = j;
			} changer[i][j] = j changer[i][j] changer[i] changer i j j for(int i = 1;i <= changeNum; i++){
			String[] tmpStr = br.readLine().split(",");
			changer[i][Integer.parseInt(tmpStr[0])] = Integer.parseInt(tmpStr[1]);
			changer[i][Integer.parseInt(tmpStr[1])] = Integer.parseInt(tmpStr[0]);
		} int i = 1; int i = 1; i 1 i <= changeNum i changeNum i++ i++ i {
			String[] tmpStr = br.readLine().split(",");
			changer[i][Integer.parseInt(tmpStr[0])] = Integer.parseInt(tmpStr[1]);
			changer[i][Integer.parseInt(tmpStr[1])] = Integer.parseInt(tmpStr[0]);
		} {
			String[] tmpStr = br.readLine().split(",");
			changer[i][Integer.parseInt(tmpStr[0])] = Integer.parseInt(tmpStr[1]);
			changer[i][Integer.parseInt(tmpStr[1])] = Integer.parseInt(tmpStr[0]);
		} String[] tmpStr = br.readLine().split(","); tmpStr br.readLine().split(",") br.readLine().split br.readLine() br.readLine br "," changer[i][Integer.parseInt(tmpStr[0])] = Integer.parseInt(tmpStr[1]) changer[i][Integer.parseInt(tmpStr[0])] changer[i] changer i Integer.parseInt(tmpStr[0]) Integer.parseInt Integer tmpStr[0] tmpStr 0 Integer.parseInt(tmpStr[1]) Integer.parseInt Integer tmpStr[1] tmpStr 1 changer[i][Integer.parseInt(tmpStr[1])] = Integer.parseInt(tmpStr[0]) changer[i][Integer.parseInt(tmpStr[1])] changer[i] changer i Integer.parseInt(tmpStr[1]) Integer.parseInt Integer tmpStr[1] tmpStr 1 Integer.parseInt(tmpStr[0]) Integer.parseInt Integer tmpStr[0] tmpStr 0 int[] answer = new int[lineNum + 1]; answer new int[lineNum + 1] lineNum + 1 lineNum 1 for(int i = 1; i <= lineNum ; i++){
			int tmpAnswer = i;

			for(int j = 1; j <= changeNum ; j++){
				//System.out.println("next "+changer[j][tmpAnswer]);
				tmpAnswer = changer[j][tmpAnswer];
			}

			answer[tmpAnswer] = i;
		} int i = 1; int i = 1; i 1 i <= lineNum i lineNum i++ i++ i {
			int tmpAnswer = i;

			for(int j = 1; j <= changeNum ; j++){
				//System.out.println("next "+changer[j][tmpAnswer]);
				tmpAnswer = changer[j][tmpAnswer];
			}

			answer[tmpAnswer] = i;
		} {
			int tmpAnswer = i;

			for(int j = 1; j <= changeNum ; j++){
				//System.out.println("next "+changer[j][tmpAnswer]);
				tmpAnswer = changer[j][tmpAnswer];
			}

			answer[tmpAnswer] = i;
		} int tmpAnswer = i; tmpAnswer i for(int j = 1; j <= changeNum ; j++){
				//System.out.println("next "+changer[j][tmpAnswer]);
				tmpAnswer = changer[j][tmpAnswer];
			} int j = 1; int j = 1; j 1 j <= changeNum j changeNum j++ j++ j {
				//System.out.println("next "+changer[j][tmpAnswer]);
				tmpAnswer = changer[j][tmpAnswer];
			} {
				//System.out.println("next "+changer[j][tmpAnswer]);
				tmpAnswer = changer[j][tmpAnswer];
			} tmpAnswer = changer[j][tmpAnswer] tmpAnswer changer[j][tmpAnswer] changer[j] changer j tmpAnswer answer[tmpAnswer] = i answer[tmpAnswer] answer tmpAnswer i for(int i = 1; i <= lineNum; i++){
			System.out.println(answer[i]);
		} int i = 1; int i = 1; i 1 i <= lineNum i lineNum i++ i++ i {
			System.out.println(answer[i]);
		} {
			System.out.println(answer[i]);
		} System.out.println(answer[i]) System.out.println System.out System System.out answer[i] answer i String[] args args public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int lineNum = Integer.parseInt(br.readLine());
		int changeNum = Integer.parseInt(br.readLine());

		int[][] changer = new int[changeNum+1][lineNum+1];
		//?????????
		for(int i = 1; i <= changeNum ; i++){
			for(int j = 1; j <= lineNum; j++){
				changer[i][j] = j;
			}
		}

		//??\???????????????
		for(int i = 1;i <= changeNum; i++){
			String[] tmpStr = br.readLine().split(",");
			changer[i][Integer.parseInt(tmpStr[0])] = Integer.parseInt(tmpStr[1]);
			changer[i][Integer.parseInt(tmpStr[1])] = Integer.parseInt(tmpStr[0]);
		}

		//???????????????
		int[] answer = new int[lineNum + 1];

		for(int i = 1; i <= lineNum ; i++){
			int tmpAnswer = i;

			for(int j = 1; j <= changeNum ; j++){
				//System.out.println("next "+changer[j][tmpAnswer]);
				tmpAnswer = changer[j][tmpAnswer];
			}

			answer[tmpAnswer] = i;
		}

		for(int i = 1; i <= lineNum; i++){
			System.out.println(answer[i]);
		}
	}

} public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int lineNum = Integer.parseInt(br.readLine());
		int changeNum = Integer.parseInt(br.readLine());

		int[][] changer = new int[changeNum+1][lineNum+1];
		//?????????
		for(int i = 1; i <= changeNum ; i++){
			for(int j = 1; j <= lineNum; j++){
				changer[i][j] = j;
			}
		}

		//??\???????????????
		for(int i = 1;i <= changeNum; i++){
			String[] tmpStr = br.readLine().split(",");
			changer[i][Integer.parseInt(tmpStr[0])] = Integer.parseInt(tmpStr[1]);
			changer[i][Integer.parseInt(tmpStr[1])] = Integer.parseInt(tmpStr[0]);
		}

		//???????????????
		int[] answer = new int[lineNum + 1];

		for(int i = 1; i <= lineNum ; i++){
			int tmpAnswer = i;

			for(int j = 1; j <= changeNum ; j++){
				//System.out.println("next "+changer[j][tmpAnswer]);
				tmpAnswer = changer[j][tmpAnswer];
			}

			answer[tmpAnswer] = i;
		}

		for(int i = 1; i <= lineNum; i++){
			System.out.println(answer[i]);
		}
	}

} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int lineNum = Integer.parseInt(br.readLine());
		int changeNum = Integer.parseInt(br.readLine());

		int[][] changer = new int[changeNum+1][lineNum+1];
		//?????????
		for(int i = 1; i <= changeNum ; i++){
			for(int j = 1; j <= lineNum; j++){
				changer[i][j] = j;
			}
		}

		//??\???????????????
		for(int i = 1;i <= changeNum; i++){
			String[] tmpStr = br.readLine().split(",");
			changer[i][Integer.parseInt(tmpStr[0])] = Integer.parseInt(tmpStr[1]);
			changer[i][Integer.parseInt(tmpStr[1])] = Integer.parseInt(tmpStr[0]);
		}

		//???????????????
		int[] answer = new int[lineNum + 1];

		for(int i = 1; i <= lineNum ; i++){
			int tmpAnswer = i;

			for(int j = 1; j <= changeNum ; j++){
				//System.out.println("next "+changer[j][tmpAnswer]);
				tmpAnswer = changer[j][tmpAnswer];
			}

			answer[tmpAnswer] = i;
		}

		for(int i = 1; i <= lineNum; i++){
			System.out.println(answer[i]);
		}
	}

}