import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    int M = scanner.nextInt();
    int P[] = new int[N];
    int a,b,x;
    String[] str;

    for(int i=0;i<M;i++){
      P[i] = i + 1;
    }

    for(int i=0;i<M;i++){
      str = scanner.next().split(",");
  		a = Integer.parseInt(str[0]);
  		b = Integer.parseInt(str[1]);
      x = P[a-1];
      P[a-1] = P[b-1];
      P[b-1] = x;
    }

    for(int i=0;i<M;i++){
      System.out.println(P[i]);
    }

  }
}
 import java.util.Scanner; Scanner java.util class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    int M = scanner.nextInt();
    int P[] = new int[N];
    int a,b,x;
    String[] str;

    for(int i=0;i<M;i++){
      P[i] = i + 1;
    }

    for(int i=0;i<M;i++){
      str = scanner.next().split(",");
  		a = Integer.parseInt(str[0]);
  		b = Integer.parseInt(str[1]);
      x = P[a-1];
      P[a-1] = P[b-1];
      P[b-1] = x;
    }

    for(int i=0;i<M;i++){
      System.out.println(P[i]);
    }

  }
} Main public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    int M = scanner.nextInt();
    int P[] = new int[N];
    int a,b,x;
    String[] str;

    for(int i=0;i<M;i++){
      P[i] = i + 1;
    }

    for(int i=0;i<M;i++){
      str = scanner.next().split(",");
  		a = Integer.parseInt(str[0]);
  		b = Integer.parseInt(str[1]);
      x = P[a-1];
      P[a-1] = P[b-1];
      P[b-1] = x;
    }

    for(int i=0;i<M;i++){
      System.out.println(P[i]);
    }

  } main {
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    int M = scanner.nextInt();
    int P[] = new int[N];
    int a,b,x;
    String[] str;

    for(int i=0;i<M;i++){
      P[i] = i + 1;
    }

    for(int i=0;i<M;i++){
      str = scanner.next().split(",");
  		a = Integer.parseInt(str[0]);
  		b = Integer.parseInt(str[1]);
      x = P[a-1];
      P[a-1] = P[b-1];
      P[b-1] = x;
    }

    for(int i=0;i<M;i++){
      System.out.println(P[i]);
    }

  } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int N = scanner.nextInt(); N scanner.nextInt() scanner.nextInt scanner int M = scanner.nextInt(); M scanner.nextInt() scanner.nextInt scanner int P[] = new int[N]; P new int[N] N int a a b b x; x String[] str; str for(int i=0;i<M;i++){
      P[i] = i + 1;
    } int i=0; int i=0; i 0 i<M i M i++ i++ i {
      P[i] = i + 1;
    } {
      P[i] = i + 1;
    } P[i] = i + 1 P[i] P i i + 1 i 1 for(int i=0;i<M;i++){
      str = scanner.next().split(",");
  		a = Integer.parseInt(str[0]);
  		b = Integer.parseInt(str[1]);
      x = P[a-1];
      P[a-1] = P[b-1];
      P[b-1] = x;
    } int i=0; int i=0; i 0 i<M i M i++ i++ i {
      str = scanner.next().split(",");
  		a = Integer.parseInt(str[0]);
  		b = Integer.parseInt(str[1]);
      x = P[a-1];
      P[a-1] = P[b-1];
      P[b-1] = x;
    } {
      str = scanner.next().split(",");
  		a = Integer.parseInt(str[0]);
  		b = Integer.parseInt(str[1]);
      x = P[a-1];
      P[a-1] = P[b-1];
      P[b-1] = x;
    } str = scanner.next().split(",") str scanner.next().split(",") scanner.next().split scanner.next() scanner.next scanner "," a = Integer.parseInt(str[0]) a Integer.parseInt(str[0]) Integer.parseInt Integer str[0] str 0 b = Integer.parseInt(str[1]) b Integer.parseInt(str[1]) Integer.parseInt Integer str[1] str 1 x = P[a-1] x P[a-1] P a-1 a 1 P[a-1] = P[b-1] P[a-1] P a-1 a 1 P[b-1] P b-1 b 1 P[b-1] = x P[b-1] P b-1 b 1 x for(int i=0;i<M;i++){
      System.out.println(P[i]);
    } int i=0; int i=0; i 0 i<M i M i++ i++ i {
      System.out.println(P[i]);
    } {
      System.out.println(P[i]);
    } System.out.println(P[i]) System.out.println System.out System System.out P[i] P i String[] args args
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    int M = scanner.nextInt();
    int P[] = new int[N];
    int a,b,x;
    String[] str;

    for(int i=0;i<M;i++){
      P[i] = i + 1;
    }

    for(int i=0;i<M;i++){
      str = scanner.next().split(",");
  		a = Integer.parseInt(str[0]);
  		b = Integer.parseInt(str[1]);
      x = P[a-1];
      P[a-1] = P[b-1];
      P[b-1] = x;
    }

    for(int i=0;i<M;i++){
      System.out.println(P[i]);
    }

  }
}

