import java.util.Scanner;

public class Main{
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();
		Bridge[] b = new Bridge[n];
		for(int i = 0; i < n; i++){
			String in = sc.next();
			int x = Integer.parseInt(in.substring(0, in.indexOf(",")));
			int y = Integer.parseInt(in.substring(in.indexOf(",") + 1,
					in.length()));
			b[i] = new Bridge(x, y);
		}
		Lot l = new Lot(b);
		
		int[] result = new int[w];
		for(int i = 1; i <= w; i++){
			result[l.lot(i) - 1] = i;
		}
		for(int i = 0; i < result.length; i++)
			System.out.println(result[i]);
		sc.close();
	}
	
}

class Bridge{
	
	int x;
	int y;
	
	Bridge(int x, int y){
		this.x = x;
		this.y = y;
	}
}

class Lot{
	
	Bridge[] bridges;
	
	Lot(Bridge... b){
		this.bridges = b;
	}
	
	int lot(int num){
		int result = num;
		for(Bridge b: this.bridges){
			if(result == b.x)
				result = b.y;
			else if(result == b.y) result = b.x;
		}
		return result;
	}
	
} import java.util.Scanner; Scanner java.util public class Main{
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();
		Bridge[] b = new Bridge[n];
		for(int i = 0; i < n; i++){
			String in = sc.next();
			int x = Integer.parseInt(in.substring(0, in.indexOf(",")));
			int y = Integer.parseInt(in.substring(in.indexOf(",") + 1,
					in.length()));
			b[i] = new Bridge(x, y);
		}
		Lot l = new Lot(b);
		
		int[] result = new int[w];
		for(int i = 1; i <= w; i++){
			result[l.lot(i) - 1] = i;
		}
		for(int i = 0; i < result.length; i++)
			System.out.println(result[i]);
		sc.close();
	}
	
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();
		Bridge[] b = new Bridge[n];
		for(int i = 0; i < n; i++){
			String in = sc.next();
			int x = Integer.parseInt(in.substring(0, in.indexOf(",")));
			int y = Integer.parseInt(in.substring(in.indexOf(",") + 1,
					in.length()));
			b[i] = new Bridge(x, y);
		}
		Lot l = new Lot(b);
		
		int[] result = new int[w];
		for(int i = 1; i <= w; i++){
			result[l.lot(i) - 1] = i;
		}
		for(int i = 0; i < result.length; i++)
			System.out.println(result[i]);
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();
		Bridge[] b = new Bridge[n];
		for(int i = 0; i < n; i++){
			String in = sc.next();
			int x = Integer.parseInt(in.substring(0, in.indexOf(",")));
			int y = Integer.parseInt(in.substring(in.indexOf(",") + 1,
					in.length()));
			b[i] = new Bridge(x, y);
		}
		Lot l = new Lot(b);
		
		int[] result = new int[w];
		for(int i = 1; i <= w; i++){
			result[l.lot(i) - 1] = i;
		}
		for(int i = 0; i < result.length; i++)
			System.out.println(result[i]);
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int w = sc.nextInt(); w sc.nextInt() sc.nextInt sc int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc Bridge[] b = new Bridge[n]; b new Bridge[n] n for(int i = 0; i < n; i++){
			String in = sc.next();
			int x = Integer.parseInt(in.substring(0, in.indexOf(",")));
			int y = Integer.parseInt(in.substring(in.indexOf(",") + 1,
					in.length()));
			b[i] = new Bridge(x, y);
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			String in = sc.next();
			int x = Integer.parseInt(in.substring(0, in.indexOf(",")));
			int y = Integer.parseInt(in.substring(in.indexOf(",") + 1,
					in.length()));
			b[i] = new Bridge(x, y);
		} {
			String in = sc.next();
			int x = Integer.parseInt(in.substring(0, in.indexOf(",")));
			int y = Integer.parseInt(in.substring(in.indexOf(",") + 1,
					in.length()));
			b[i] = new Bridge(x, y);
		} String in = sc.next(); in sc.next() sc.next sc int x = Integer.parseInt(in.substring(0, in.indexOf(","))); x Integer.parseInt(in.substring(0, in.indexOf(","))) Integer.parseInt Integer in.substring(0, in.indexOf(",")) in.substring in 0 in.indexOf(",") in.indexOf in "," int y = Integer.parseInt(in.substring(in.indexOf(",") + 1,
					in.length())); y Integer.parseInt(in.substring(in.indexOf(",") + 1,
					in.length())) Integer.parseInt Integer in.substring(in.indexOf(",") + 1,
					in.length()) in.substring in in.indexOf(",") + 1 in.indexOf(",") in.indexOf in "," 1 in.length() in.length in b[i] = new Bridge(x, y) b[i] b i new Bridge(x, y) Lot l = new Lot(b); l new Lot(b) int[] result = new int[w]; result new int[w] w for(int i = 1; i <= w; i++){
			result[l.lot(i) - 1] = i;
		} int i = 1; int i = 1; i 1 i <= w i w i++ i++ i {
			result[l.lot(i) - 1] = i;
		} {
			result[l.lot(i) - 1] = i;
		} result[l.lot(i) - 1] = i result[l.lot(i) - 1] result l.lot(i) - 1 l.lot(i) l.lot l i 1 i for(int i = 0; i < result.length; i++)
			System.out.println(result[i]); int i = 0; int i = 0; i 0 i < result.length i result.length result result.length i++ i++ i System.out.println(result[i]); System.out.println(result[i]) System.out.println System.out System System.out result[i] result i sc.close() sc.close sc String[] args args class Bridge{
	
	int x;
	int y;
	
	Bridge(int x, int y){
		this.x = x;
		this.y = y;
	}
} Bridge int x; x int y; y Bridge(int x, int y){
		this.x = x;
		this.y = y;
	} Bridge {
		this.x = x;
		this.y = y;
	} this.x = x this.x this this.x x this.y = y this.y this this.y y int x x int y y class Lot{
	
	Bridge[] bridges;
	
	Lot(Bridge... b){
		this.bridges = b;
	}
	
	int lot(int num){
		int result = num;
		for(Bridge b: this.bridges){
			if(result == b.x)
				result = b.y;
			else if(result == b.y) result = b.x;
		}
		return result;
	}
	
} Lot Bridge[] bridges; bridges Lot(Bridge... b){
		this.bridges = b;
	} Lot {
		this.bridges = b;
	} this.bridges = b this.bridges this this.bridges b Bridge... b b int lot(int num){
		int result = num;
		for(Bridge b: this.bridges){
			if(result == b.x)
				result = b.y;
			else if(result == b.y) result = b.x;
		}
		return result;
	} lot {
		int result = num;
		for(Bridge b: this.bridges){
			if(result == b.x)
				result = b.y;
			else if(result == b.y) result = b.x;
		}
		return result;
	} int result = num; result num for(Bridge b: this.bridges){
			if(result == b.x)
				result = b.y;
			else if(result == b.y) result = b.x;
		} Bridge b this.bridges this this.bridges {
			if(result == b.x)
				result = b.y;
			else if(result == b.y) result = b.x;
		} {
			if(result == b.x)
				result = b.y;
			else if(result == b.y) result = b.x;
		} if(result == b.x)
				result = b.y;
			else if(result == b.y) result = b.x; result == b.x result b.x b b.x result = b.y result b.y b b.y if(result == b.y) result = b.x; result == b.y result b.y b b.y result = b.x result b.x b b.x return result; result int num num public class Main{
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();
		Bridge[] b = new Bridge[n];
		for(int i = 0; i < n; i++){
			String in = sc.next();
			int x = Integer.parseInt(in.substring(0, in.indexOf(",")));
			int y = Integer.parseInt(in.substring(in.indexOf(",") + 1,
					in.length()));
			b[i] = new Bridge(x, y);
		}
		Lot l = new Lot(b);
		
		int[] result = new int[w];
		for(int i = 1; i <= w; i++){
			result[l.lot(i) - 1] = i;
		}
		for(int i = 0; i < result.length; i++)
			System.out.println(result[i]);
		sc.close();
	}
	
} public class Main{
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();
		Bridge[] b = new Bridge[n];
		for(int i = 0; i < n; i++){
			String in = sc.next();
			int x = Integer.parseInt(in.substring(0, in.indexOf(",")));
			int y = Integer.parseInt(in.substring(in.indexOf(",") + 1,
					in.length()));
			b[i] = new Bridge(x, y);
		}
		Lot l = new Lot(b);
		
		int[] result = new int[w];
		for(int i = 1; i <= w; i++){
			result[l.lot(i) - 1] = i;
		}
		for(int i = 0; i < result.length; i++)
			System.out.println(result[i]);
		sc.close();
	}
	
} Main
import java.util.Scanner;

public class Main{
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();
		Bridge[] b = new Bridge[n];
		for(int i = 0; i < n; i++){
			String in = sc.next();
			int x = Integer.parseInt(in.substring(0, in.indexOf(",")));
			int y = Integer.parseInt(in.substring(in.indexOf(",") + 1,
					in.length()));
			b[i] = new Bridge(x, y);
		}
		Lot l = new Lot(b);
		
		int[] result = new int[w];
		for(int i = 1; i <= w; i++){
			result[l.lot(i) - 1] = i;
		}
		for(int i = 0; i < result.length; i++)
			System.out.println(result[i]);
		sc.close();
	}
	
}

class Bridge{
	
	int x;
	int y;
	
	Bridge(int x, int y){
		this.x = x;
		this.y = y;
	}
}

class Lot{
	
	Bridge[] bridges;
	
	Lot(Bridge... b){
		this.bridges = b;
	}
	
	int lot(int num){
		int result = num;
		for(Bridge b: this.bridges){
			if(result == b.x)
				result = b.y;
			else if(result == b.y) result = b.x;
		}
		return result;
	}
	
}