#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <sstream>
#include <cstdlib>
#include <cmath>
 
using namespace std;

int main(){
    int w, n;
    cin >> w;
    cin >> n;
    int stick[31] = {0};
    for(int i = 1; i <= w; i++){
        stick[i] = i;
    }

    for(int i = 0; i < n; i++){
        int a, b;
        int temp;
        scanf("%d,%d", &a, &b);
        temp = stick[a];
        stick[a] = stick[b];
        stick[b] = temp;
    }

    for(int i = 1; i <= w; i++){
        cout << stick[i] << endl;
    }

    return 0;
}