#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    int w, n, num[31];
    int i;

    cin >> w;

    for (i = 1; i <= w; i++){
        num[i] = i;
    }

    cin >> n;
    for (i = 0; i < n; i++){
        char c;
        int a, b;
        cin >> a >> c >> b;
        swap(num[a], num[b]);
    }

    for (i = 1; i <= w; i++){
        cout << num[i] << endl;
    }
    return (0);
}