#include <iostream>

using namespace std;

int main()
{
    int w, n;
    char comma;
    int a, b;
    int ans[32];
    
    cin >> w >> n;
    for (int i = 1; i <= w; i++)
        ans[i] = i;

    for (int i = 0; i < n; i++) {
        cin >> a >> comma >> b;
        int tmp = ans[a];
        ans[a] = ans[b];
        ans[b] = tmp;
    }

    for (int i = 1; i <= w; i++)
        cout << ans[i] << endl;

    return 0;
}