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();// 横棒の本数
    int a[] = new int[n];
    int b[] = new int[n];

    for (int i = 0; i < n; i++) {// 横棒の入力
      String ab = sc.next();
      String ab_p[] = ab.split(",");
      a[i] = Integer.parseInt(ab_p[0]);
      b[i] = Integer.parseInt(ab_p[1]);
    }

    for (int i = 1; i <= w; i++) {// 左から右
      int k = i;
      for (int j = n - 1; j >= 0; j--) {// 下から上へ辿る
        if (k == a[j]) {
          k = b[j];
        } else if (k == b[j]) {
          k = a[j];
        }
      }
      System.out.printf("%d\n", k);
    }
  }
}
 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();// 横棒の本数
    int a[] = new int[n];
    int b[] = new int[n];

    for (int i = 0; i < n; i++) {// 横棒の入力
      String ab = sc.next();
      String ab_p[] = ab.split(",");
      a[i] = Integer.parseInt(ab_p[0]);
      b[i] = Integer.parseInt(ab_p[1]);
    }

    for (int i = 1; i <= w; i++) {// 左から右
      int k = i;
      for (int j = n - 1; j >= 0; j--) {// 下から上へ辿る
        if (k == a[j]) {
          k = b[j];
        } else if (k == b[j]) {
          k = a[j];
        }
      }
      System.out.printf("%d\n", k);
    }
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int w = sc.nextInt();// 縦線の本数
    int n = sc.nextInt();// 横棒の本数
    int a[] = new int[n];
    int b[] = new int[n];

    for (int i = 0; i < n; i++) {// 横棒の入力
      String ab = sc.next();
      String ab_p[] = ab.split(",");
      a[i] = Integer.parseInt(ab_p[0]);
      b[i] = Integer.parseInt(ab_p[1]);
    }

    for (int i = 1; i <= w; i++) {// 左から右
      int k = i;
      for (int j = n - 1; j >= 0; j--) {// 下から上へ辿る
        if (k == a[j]) {
          k = b[j];
        } else if (k == b[j]) {
          k = a[j];
        }
      }
      System.out.printf("%d\n", k);
    }
  } main {
    Scanner sc = new Scanner(System.in);
    int w = sc.nextInt();// 縦線の本数
    int n = sc.nextInt();// 横棒の本数
    int a[] = new int[n];
    int b[] = new int[n];

    for (int i = 0; i < n; i++) {// 横棒の入力
      String ab = sc.next();
      String ab_p[] = ab.split(",");
      a[i] = Integer.parseInt(ab_p[0]);
      b[i] = Integer.parseInt(ab_p[1]);
    }

    for (int i = 1; i <= w; i++) {// 左から右
      int k = i;
      for (int j = n - 1; j >= 0; j--) {// 下から上へ辿る
        if (k == a[j]) {
          k = b[j];
        } else if (k == b[j]) {
          k = a[j];
        }
      }
      System.out.printf("%d\n", k);
    }
  } 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 int a[] = new int[n]; a new int[n] n int b[] = new int[n]; b new int[n] n for (int i = 0; i < n; i++) {// 横棒の入力
      String ab = sc.next();
      String ab_p[] = ab.split(",");
      a[i] = Integer.parseInt(ab_p[0]);
      b[i] = Integer.parseInt(ab_p[1]);
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {// 横棒の入力
      String ab = sc.next();
      String ab_p[] = ab.split(",");
      a[i] = Integer.parseInt(ab_p[0]);
      b[i] = Integer.parseInt(ab_p[1]);
    } {// 横棒の入力
      String ab = sc.next();
      String ab_p[] = ab.split(",");
      a[i] = Integer.parseInt(ab_p[0]);
      b[i] = Integer.parseInt(ab_p[1]);
    } String ab = sc.next(); ab sc.next() sc.next sc String ab_p[] = ab.split(","); ab_p ab.split(",") ab.split ab "," a[i] = Integer.parseInt(ab_p[0]) a[i] a i Integer.parseInt(ab_p[0]) Integer.parseInt Integer ab_p[0] ab_p 0 b[i] = Integer.parseInt(ab_p[1]) b[i] b i Integer.parseInt(ab_p[1]) Integer.parseInt Integer ab_p[1] ab_p 1 for (int i = 1; i <= w; i++) {// 左から右
      int k = i;
      for (int j = n - 1; j >= 0; j--) {// 下から上へ辿る
        if (k == a[j]) {
          k = b[j];
        } else if (k == b[j]) {
          k = a[j];
        }
      }
      System.out.printf("%d\n", k);
    } int i = 1; int i = 1; i 1 i <= w i w i++ i++ i {// 左から右
      int k = i;
      for (int j = n - 1; j >= 0; j--) {// 下から上へ辿る
        if (k == a[j]) {
          k = b[j];
        } else if (k == b[j]) {
          k = a[j];
        }
      }
      System.out.printf("%d\n", k);
    } {// 左から右
      int k = i;
      for (int j = n - 1; j >= 0; j--) {// 下から上へ辿る
        if (k == a[j]) {
          k = b[j];
        } else if (k == b[j]) {
          k = a[j];
        }
      }
      System.out.printf("%d\n", k);
    } int k = i; k i for (int j = n - 1; j >= 0; j--) {// 下から上へ辿る
        if (k == a[j]) {
          k = b[j];
        } else if (k == b[j]) {
          k = a[j];
        }
      } int j = n - 1; int j = n - 1; j n - 1 n 1 j >= 0 j 0 j-- j-- j {// 下から上へ辿る
        if (k == a[j]) {
          k = b[j];
        } else if (k == b[j]) {
          k = a[j];
        }
      } {// 下から上へ辿る
        if (k == a[j]) {
          k = b[j];
        } else if (k == b[j]) {
          k = a[j];
        }
      } if (k == a[j]) {
          k = b[j];
        } else if (k == b[j]) {
          k = a[j];
        } k == a[j] k a[j] a j {
          k = b[j];
        } k = b[j] k b[j] b j if (k == b[j]) {
          k = a[j];
        } k == b[j] k b[j] b j {
          k = a[j];
        } k = a[j] k a[j] a j System.out.printf("%d\n", k) System.out.printf System.out System System.out "%d\n" k String[] args args public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int w = sc.nextInt();// 縦線の本数
    int n = sc.nextInt();// 横棒の本数
    int a[] = new int[n];
    int b[] = new int[n];

    for (int i = 0; i < n; i++) {// 横棒の入力
      String ab = sc.next();
      String ab_p[] = ab.split(",");
      a[i] = Integer.parseInt(ab_p[0]);
      b[i] = Integer.parseInt(ab_p[1]);
    }

    for (int i = 1; i <= w; i++) {// 左から右
      int k = i;
      for (int j = n - 1; j >= 0; j--) {// 下から上へ辿る
        if (k == a[j]) {
          k = b[j];
        } else if (k == b[j]) {
          k = a[j];
        }
      }
      System.out.printf("%d\n", k);
    }
  }
} public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int w = sc.nextInt();// 縦線の本数
    int n = sc.nextInt();// 横棒の本数
    int a[] = new int[n];
    int b[] = new int[n];

    for (int i = 0; i < n; i++) {// 横棒の入力
      String ab = sc.next();
      String ab_p[] = ab.split(",");
      a[i] = Integer.parseInt(ab_p[0]);
      b[i] = Integer.parseInt(ab_p[1]);
    }

    for (int i = 1; i <= w; i++) {// 左から右
      int k = i;
      for (int j = n - 1; j >= 0; j--) {// 下から上へ辿る
        if (k == a[j]) {
          k = b[j];
        } else if (k == b[j]) {
          k = a[j];
        }
      }
      System.out.printf("%d\n", k);
    }
  }
} 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();// 横棒の本数
    int a[] = new int[n];
    int b[] = new int[n];

    for (int i = 0; i < n; i++) {// 横棒の入力
      String ab = sc.next();
      String ab_p[] = ab.split(",");
      a[i] = Integer.parseInt(ab_p[0]);
      b[i] = Integer.parseInt(ab_p[1]);
    }

    for (int i = 1; i <= w; i++) {// 左から右
      int k = i;
      for (int j = n - 1; j >= 0; j--) {// 下から上へ辿る
        if (k == a[j]) {
          k = b[j];
        } else if (k == b[j]) {
          k = a[j];
        }
      }
      System.out.printf("%d\n", k);
    }
  }
}

