import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static int w, h;
	static int[]amida;
	public static void main(String[] args) {
		while(read()){
			solve();
		}
	}
	static boolean read(){
		if(!sc.hasNext())return false;
		w = sc.nextInt(); h = sc.nextInt();
		amida = new int[w+1];
		String line;
		String[] devide = new String[2];
		for(int i = 1; i < w+1; i++)
			amida[i] = i;
		for(int i = 0; i < h; i++){
			line = sc.next();
			devide = line.split(",");
			int exIndex1 = Integer.parseInt(devide[0]);
			int exIndex2 = Integer.parseInt(devide[1]);
			int temp = amida[exIndex1];
			amida[exIndex1] = amida[exIndex2];
			amida[exIndex2] = temp;
		}
		return true;
	}
	static void solve(){
		for(int i = 1; i < w+1; i++){
			System.out.println(amida[i]);
		}
	}

} import java.util.*; util.* java public class Main {
	static Scanner sc = new Scanner(System.in);
	static int w, h;
	static int[]amida;
	public static void main(String[] args) {
		while(read()){
			solve();
		}
	}
	static boolean read(){
		if(!sc.hasNext())return false;
		w = sc.nextInt(); h = sc.nextInt();
		amida = new int[w+1];
		String line;
		String[] devide = new String[2];
		for(int i = 1; i < w+1; i++)
			amida[i] = i;
		for(int i = 0; i < h; i++){
			line = sc.next();
			devide = line.split(",");
			int exIndex1 = Integer.parseInt(devide[0]);
			int exIndex2 = Integer.parseInt(devide[1]);
			int temp = amida[exIndex1];
			amida[exIndex1] = amida[exIndex2];
			amida[exIndex2] = temp;
		}
		return true;
	}
	static void solve(){
		for(int i = 1; i < w+1; i++){
			System.out.println(amida[i]);
		}
	}

} Main static Scanner sc = new Scanner(System.in); sc new Scanner(System.in) static int w w h; h static int[]amida; amida public static void main(String[] args) {
		while(read()){
			solve();
		}
	} main {
		while(read()){
			solve();
		}
	} while(read()){
			solve();
		} read() read {
			solve();
		} solve() solve String[] args args static boolean read(){
		if(!sc.hasNext())return false;
		w = sc.nextInt(); h = sc.nextInt();
		amida = new int[w+1];
		String line;
		String[] devide = new String[2];
		for(int i = 1; i < w+1; i++)
			amida[i] = i;
		for(int i = 0; i < h; i++){
			line = sc.next();
			devide = line.split(",");
			int exIndex1 = Integer.parseInt(devide[0]);
			int exIndex2 = Integer.parseInt(devide[1]);
			int temp = amida[exIndex1];
			amida[exIndex1] = amida[exIndex2];
			amida[exIndex2] = temp;
		}
		return true;
	} read {
		if(!sc.hasNext())return false;
		w = sc.nextInt(); h = sc.nextInt();
		amida = new int[w+1];
		String line;
		String[] devide = new String[2];
		for(int i = 1; i < w+1; i++)
			amida[i] = i;
		for(int i = 0; i < h; i++){
			line = sc.next();
			devide = line.split(",");
			int exIndex1 = Integer.parseInt(devide[0]);
			int exIndex2 = Integer.parseInt(devide[1]);
			int temp = amida[exIndex1];
			amida[exIndex1] = amida[exIndex2];
			amida[exIndex2] = temp;
		}
		return true;
	} if(!sc.hasNext())return false; !sc.hasNext() sc.hasNext() sc.hasNext sc return false; false w = sc.nextInt() w sc.nextInt() sc.nextInt sc h = sc.nextInt() h sc.nextInt() sc.nextInt sc amida = new int[w+1] amida new int[w+1] w+1 w 1 String line; line String[] devide = new String[2]; devide new String[2] 2 for(int i = 1; i < w+1; i++)
			amida[i] = i; int i = 1; int i = 1; i 1 i < w+1 i w+1 w 1 i++ i++ i amida[i] = i; amida[i] = i amida[i] amida i i for(int i = 0; i < h; i++){
			line = sc.next();
			devide = line.split(",");
			int exIndex1 = Integer.parseInt(devide[0]);
			int exIndex2 = Integer.parseInt(devide[1]);
			int temp = amida[exIndex1];
			amida[exIndex1] = amida[exIndex2];
			amida[exIndex2] = temp;
		} int i = 0; int i = 0; i 0 i < h i h i++ i++ i {
			line = sc.next();
			devide = line.split(",");
			int exIndex1 = Integer.parseInt(devide[0]);
			int exIndex2 = Integer.parseInt(devide[1]);
			int temp = amida[exIndex1];
			amida[exIndex1] = amida[exIndex2];
			amida[exIndex2] = temp;
		} {
			line = sc.next();
			devide = line.split(",");
			int exIndex1 = Integer.parseInt(devide[0]);
			int exIndex2 = Integer.parseInt(devide[1]);
			int temp = amida[exIndex1];
			amida[exIndex1] = amida[exIndex2];
			amida[exIndex2] = temp;
		} line = sc.next() line sc.next() sc.next sc devide = line.split(",") devide line.split(",") line.split line "," int exIndex1 = Integer.parseInt(devide[0]); exIndex1 Integer.parseInt(devide[0]) Integer.parseInt Integer devide[0] devide 0 int exIndex2 = Integer.parseInt(devide[1]); exIndex2 Integer.parseInt(devide[1]) Integer.parseInt Integer devide[1] devide 1 int temp = amida[exIndex1]; temp amida[exIndex1] amida exIndex1 amida[exIndex1] = amida[exIndex2] amida[exIndex1] amida exIndex1 amida[exIndex2] amida exIndex2 amida[exIndex2] = temp amida[exIndex2] amida exIndex2 temp return true; true static void solve(){
		for(int i = 1; i < w+1; i++){
			System.out.println(amida[i]);
		}
	} solve {
		for(int i = 1; i < w+1; i++){
			System.out.println(amida[i]);
		}
	} for(int i = 1; i < w+1; i++){
			System.out.println(amida[i]);
		} int i = 1; int i = 1; i 1 i < w+1 i w+1 w 1 i++ i++ i {
			System.out.println(amida[i]);
		} {
			System.out.println(amida[i]);
		} System.out.println(amida[i]) System.out.println System.out System System.out amida[i] amida i public class Main {
	static Scanner sc = new Scanner(System.in);
	static int w, h;
	static int[]amida;
	public static void main(String[] args) {
		while(read()){
			solve();
		}
	}
	static boolean read(){
		if(!sc.hasNext())return false;
		w = sc.nextInt(); h = sc.nextInt();
		amida = new int[w+1];
		String line;
		String[] devide = new String[2];
		for(int i = 1; i < w+1; i++)
			amida[i] = i;
		for(int i = 0; i < h; i++){
			line = sc.next();
			devide = line.split(",");
			int exIndex1 = Integer.parseInt(devide[0]);
			int exIndex2 = Integer.parseInt(devide[1]);
			int temp = amida[exIndex1];
			amida[exIndex1] = amida[exIndex2];
			amida[exIndex2] = temp;
		}
		return true;
	}
	static void solve(){
		for(int i = 1; i < w+1; i++){
			System.out.println(amida[i]);
		}
	}

} public class Main {
	static Scanner sc = new Scanner(System.in);
	static int w, h;
	static int[]amida;
	public static void main(String[] args) {
		while(read()){
			solve();
		}
	}
	static boolean read(){
		if(!sc.hasNext())return false;
		w = sc.nextInt(); h = sc.nextInt();
		amida = new int[w+1];
		String line;
		String[] devide = new String[2];
		for(int i = 1; i < w+1; i++)
			amida[i] = i;
		for(int i = 0; i < h; i++){
			line = sc.next();
			devide = line.split(",");
			int exIndex1 = Integer.parseInt(devide[0]);
			int exIndex2 = Integer.parseInt(devide[1]);
			int temp = amida[exIndex1];
			amida[exIndex1] = amida[exIndex2];
			amida[exIndex2] = temp;
		}
		return true;
	}
	static void solve(){
		for(int i = 1; i < w+1; i++){
			System.out.println(amida[i]);
		}
	}

} Main
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static int w, h;
	static int[]amida;
	public static void main(String[] args) {
		while(read()){
			solve();
		}
	}
	static boolean read(){
		if(!sc.hasNext())return false;
		w = sc.nextInt(); h = sc.nextInt();
		amida = new int[w+1];
		String line;
		String[] devide = new String[2];
		for(int i = 1; i < w+1; i++)
			amida[i] = i;
		for(int i = 0; i < h; i++){
			line = sc.next();
			devide = line.split(",");
			int exIndex1 = Integer.parseInt(devide[0]);
			int exIndex2 = Integer.parseInt(devide[1]);
			int temp = amida[exIndex1];
			amida[exIndex1] = amida[exIndex2];
			amida[exIndex2] = temp;
		}
		return true;
	}
	static void solve(){
		for(int i = 1; i < w+1; i++){
			System.out.println(amida[i]);
		}
	}

}