#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <functional>
#include <string>
#include <queue>
#include <vector>

using namespace std;

int main() {
  int w, n, ws[31];
  scanf("%d\n%d", &w, &n);
  for (int i = 1; i <= w; i++)
    ws[i] = i;
  for (int i = 0; i < n; i++) {
    int a, b;
    scanf("%d,%d", &a, &b);
    swap(ws[a], ws[b]);
  }
  for (int i = 1; i <= w; i++)
    printf("%d\n", ws[i]);
  return 0;
}