import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    void run(){
	while(sc.hasNext()){
	    int w = sc.nextInt();
	    int n = sc.nextInt();
	    int[][] lot = new int[n+1][w+1];
	    int i=1;
	    while(i<=n){
		String s = sc.next();
		int j=0;
		while(!s.substring(j, j+1).equals(",")) j++;
		int a = Integer.parseInt(s.substring(0, j));
		int b = Integer.parseInt(s.substring(j+1, s.length()));

		lot[i][a] = b;
		lot[i][b] = a;
		
		//System.out.println(i+" "+lot[i][a]+" "+lot[i][b]);
		i++;
	    }

	    i=1;
	    int[] ans = new int[w];
	    while(i<=w){
		ans[check(lot, i, n)-1] = i;
		i++;
	    }
	    for(i=0; i<w; i++)
		System.out.println(ans[i]);
	}
    }

    int check(int[][] lot, int i, int n){
	int k = 1;
	while(k<=n){
	    //System.out.println("*"+i+" "+lot[k][i]);
	    if(lot[k][i]!=0)
		i = lot[k][i];
	    k++;
	}
	//System.out.println();
	return i;
    }
} import java.util.*; util.* java public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    void run(){
	while(sc.hasNext()){
	    int w = sc.nextInt();
	    int n = sc.nextInt();
	    int[][] lot = new int[n+1][w+1];
	    int i=1;
	    while(i<=n){
		String s = sc.next();
		int j=0;
		while(!s.substring(j, j+1).equals(",")) j++;
		int a = Integer.parseInt(s.substring(0, j));
		int b = Integer.parseInt(s.substring(j+1, s.length()));

		lot[i][a] = b;
		lot[i][b] = a;
		
		//System.out.println(i+" "+lot[i][a]+" "+lot[i][b]);
		i++;
	    }

	    i=1;
	    int[] ans = new int[w];
	    while(i<=w){
		ans[check(lot, i, n)-1] = i;
		i++;
	    }
	    for(i=0; i<w; i++)
		System.out.println(ans[i]);
	}
    }

    int check(int[][] lot, int i, int n){
	int k = 1;
	while(k<=n){
	    //System.out.println("*"+i+" "+lot[k][i]);
	    if(lot[k][i]!=0)
		i = lot[k][i];
	    k++;
	}
	//System.out.println();
	return i;
    }
} Main Scanner sc = new Scanner(System.in); sc new Scanner(System.in) public static void main(String[] args){
	new Main().run();
    } main {
	new Main().run();
    } new Main().run() new Main().run new Main() String[] args args void run(){
	while(sc.hasNext()){
	    int w = sc.nextInt();
	    int n = sc.nextInt();
	    int[][] lot = new int[n+1][w+1];
	    int i=1;
	    while(i<=n){
		String s = sc.next();
		int j=0;
		while(!s.substring(j, j+1).equals(",")) j++;
		int a = Integer.parseInt(s.substring(0, j));
		int b = Integer.parseInt(s.substring(j+1, s.length()));

		lot[i][a] = b;
		lot[i][b] = a;
		
		//System.out.println(i+" "+lot[i][a]+" "+lot[i][b]);
		i++;
	    }

	    i=1;
	    int[] ans = new int[w];
	    while(i<=w){
		ans[check(lot, i, n)-1] = i;
		i++;
	    }
	    for(i=0; i<w; i++)
		System.out.println(ans[i]);
	}
    } run {
	while(sc.hasNext()){
	    int w = sc.nextInt();
	    int n = sc.nextInt();
	    int[][] lot = new int[n+1][w+1];
	    int i=1;
	    while(i<=n){
		String s = sc.next();
		int j=0;
		while(!s.substring(j, j+1).equals(",")) j++;
		int a = Integer.parseInt(s.substring(0, j));
		int b = Integer.parseInt(s.substring(j+1, s.length()));

		lot[i][a] = b;
		lot[i][b] = a;
		
		//System.out.println(i+" "+lot[i][a]+" "+lot[i][b]);
		i++;
	    }

	    i=1;
	    int[] ans = new int[w];
	    while(i<=w){
		ans[check(lot, i, n)-1] = i;
		i++;
	    }
	    for(i=0; i<w; i++)
		System.out.println(ans[i]);
	}
    } while(sc.hasNext()){
	    int w = sc.nextInt();
	    int n = sc.nextInt();
	    int[][] lot = new int[n+1][w+1];
	    int i=1;
	    while(i<=n){
		String s = sc.next();
		int j=0;
		while(!s.substring(j, j+1).equals(",")) j++;
		int a = Integer.parseInt(s.substring(0, j));
		int b = Integer.parseInt(s.substring(j+1, s.length()));

		lot[i][a] = b;
		lot[i][b] = a;
		
		//System.out.println(i+" "+lot[i][a]+" "+lot[i][b]);
		i++;
	    }

	    i=1;
	    int[] ans = new int[w];
	    while(i<=w){
		ans[check(lot, i, n)-1] = i;
		i++;
	    }
	    for(i=0; i<w; i++)
		System.out.println(ans[i]);
	} sc.hasNext() sc.hasNext sc {
	    int w = sc.nextInt();
	    int n = sc.nextInt();
	    int[][] lot = new int[n+1][w+1];
	    int i=1;
	    while(i<=n){
		String s = sc.next();
		int j=0;
		while(!s.substring(j, j+1).equals(",")) j++;
		int a = Integer.parseInt(s.substring(0, j));
		int b = Integer.parseInt(s.substring(j+1, s.length()));

		lot[i][a] = b;
		lot[i][b] = a;
		
		//System.out.println(i+" "+lot[i][a]+" "+lot[i][b]);
		i++;
	    }

	    i=1;
	    int[] ans = new int[w];
	    while(i<=w){
		ans[check(lot, i, n)-1] = i;
		i++;
	    }
	    for(i=0; i<w; i++)
		System.out.println(ans[i]);
	} int w = sc.nextInt(); w sc.nextInt() sc.nextInt sc int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[][] lot = new int[n+1][w+1]; lot new int[n+1][w+1] n+1 n 1 w+1 w 1 int i=1; i 1 while(i<=n){
		String s = sc.next();
		int j=0;
		while(!s.substring(j, j+1).equals(",")) j++;
		int a = Integer.parseInt(s.substring(0, j));
		int b = Integer.parseInt(s.substring(j+1, s.length()));

		lot[i][a] = b;
		lot[i][b] = a;
		
		//System.out.println(i+" "+lot[i][a]+" "+lot[i][b]);
		i++;
	    } i<=n i n {
		String s = sc.next();
		int j=0;
		while(!s.substring(j, j+1).equals(",")) j++;
		int a = Integer.parseInt(s.substring(0, j));
		int b = Integer.parseInt(s.substring(j+1, s.length()));

		lot[i][a] = b;
		lot[i][b] = a;
		
		//System.out.println(i+" "+lot[i][a]+" "+lot[i][b]);
		i++;
	    } String s = sc.next(); s sc.next() sc.next sc int j=0; j 0 while(!s.substring(j, j+1).equals(",")) j++; !s.substring(j, j+1).equals(",") s.substring(j, j+1).equals(",") s.substring(j, j+1).equals s.substring(j, j+1) s.substring s j j+1 j 1 "," j++ j int a = Integer.parseInt(s.substring(0, j)); a Integer.parseInt(s.substring(0, j)) Integer.parseInt Integer s.substring(0, j) s.substring s 0 j int b = Integer.parseInt(s.substring(j+1, s.length())); b Integer.parseInt(s.substring(j+1, s.length())) Integer.parseInt Integer s.substring(j+1, s.length()) s.substring s j+1 j 1 s.length() s.length s lot[i][a] = b lot[i][a] lot[i] lot i a b lot[i][b] = a lot[i][b] lot[i] lot i b a i++ i i=1 i 1 int[] ans = new int[w]; ans new int[w] w while(i<=w){
		ans[check(lot, i, n)-1] = i;
		i++;
	    } i<=w i w {
		ans[check(lot, i, n)-1] = i;
		i++;
	    } ans[check(lot, i, n)-1] = i ans[check(lot, i, n)-1] ans check(lot, i, n)-1 check(lot, i, n) check lot i n 1 i i++ i for(i=0; i<w; i++)
		System.out.println(ans[i]); i=0; i=0 i 0 i<w i w i++ i++ i System.out.println(ans[i]); System.out.println(ans[i]) System.out.println System.out System System.out ans[i] ans i int check(int[][] lot, int i, int n){
	int k = 1;
	while(k<=n){
	    //System.out.println("*"+i+" "+lot[k][i]);
	    if(lot[k][i]!=0)
		i = lot[k][i];
	    k++;
	}
	//System.out.println();
	return i;
    } check {
	int k = 1;
	while(k<=n){
	    //System.out.println("*"+i+" "+lot[k][i]);
	    if(lot[k][i]!=0)
		i = lot[k][i];
	    k++;
	}
	//System.out.println();
	return i;
    } int k = 1; k 1 while(k<=n){
	    //System.out.println("*"+i+" "+lot[k][i]);
	    if(lot[k][i]!=0)
		i = lot[k][i];
	    k++;
	} k<=n k n {
	    //System.out.println("*"+i+" "+lot[k][i]);
	    if(lot[k][i]!=0)
		i = lot[k][i];
	    k++;
	} if(lot[k][i]!=0)
		i = lot[k][i]; lot[k][i]!=0 lot[k][i] lot[k] lot k i 0 i = lot[k][i] i lot[k][i] lot[k] lot k i k++ k return i; i int[][] lot lot int i i int n n public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    void run(){
	while(sc.hasNext()){
	    int w = sc.nextInt();
	    int n = sc.nextInt();
	    int[][] lot = new int[n+1][w+1];
	    int i=1;
	    while(i<=n){
		String s = sc.next();
		int j=0;
		while(!s.substring(j, j+1).equals(",")) j++;
		int a = Integer.parseInt(s.substring(0, j));
		int b = Integer.parseInt(s.substring(j+1, s.length()));

		lot[i][a] = b;
		lot[i][b] = a;
		
		//System.out.println(i+" "+lot[i][a]+" "+lot[i][b]);
		i++;
	    }

	    i=1;
	    int[] ans = new int[w];
	    while(i<=w){
		ans[check(lot, i, n)-1] = i;
		i++;
	    }
	    for(i=0; i<w; i++)
		System.out.println(ans[i]);
	}
    }

    int check(int[][] lot, int i, int n){
	int k = 1;
	while(k<=n){
	    //System.out.println("*"+i+" "+lot[k][i]);
	    if(lot[k][i]!=0)
		i = lot[k][i];
	    k++;
	}
	//System.out.println();
	return i;
    }
} public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    void run(){
	while(sc.hasNext()){
	    int w = sc.nextInt();
	    int n = sc.nextInt();
	    int[][] lot = new int[n+1][w+1];
	    int i=1;
	    while(i<=n){
		String s = sc.next();
		int j=0;
		while(!s.substring(j, j+1).equals(",")) j++;
		int a = Integer.parseInt(s.substring(0, j));
		int b = Integer.parseInt(s.substring(j+1, s.length()));

		lot[i][a] = b;
		lot[i][b] = a;
		
		//System.out.println(i+" "+lot[i][a]+" "+lot[i][b]);
		i++;
	    }

	    i=1;
	    int[] ans = new int[w];
	    while(i<=w){
		ans[check(lot, i, n)-1] = i;
		i++;
	    }
	    for(i=0; i<w; i++)
		System.out.println(ans[i]);
	}
    }

    int check(int[][] lot, int i, int n){
	int k = 1;
	while(k<=n){
	    //System.out.println("*"+i+" "+lot[k][i]);
	    if(lot[k][i]!=0)
		i = lot[k][i];
	    k++;
	}
	//System.out.println();
	return i;
    }
} Main
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    void run(){
	while(sc.hasNext()){
	    int w = sc.nextInt();
	    int n = sc.nextInt();
	    int[][] lot = new int[n+1][w+1];
	    int i=1;
	    while(i<=n){
		String s = sc.next();
		int j=0;
		while(!s.substring(j, j+1).equals(",")) j++;
		int a = Integer.parseInt(s.substring(0, j));
		int b = Integer.parseInt(s.substring(j+1, s.length()));

		lot[i][a] = b;
		lot[i][b] = a;
		
		//System.out.println(i+" "+lot[i][a]+" "+lot[i][b]);
		i++;
	    }

	    i=1;
	    int[] ans = new int[w];
	    while(i<=w){
		ans[check(lot, i, n)-1] = i;
		i++;
	    }
	    for(i=0; i<w; i++)
		System.out.println(ans[i]);
	}
    }

    int check(int[][] lot, int i, int n){
	int k = 1;
	while(k<=n){
	    //System.out.println("*"+i+" "+lot[k][i]);
	    if(lot[k][i]!=0)
		i = lot[k][i];
	    k++;
	}
	//System.out.println();
	return i;
    }
}