#include <bits/stdc++.h>
using namespace std;

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)

int main(int argc, char *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int w, n, a, b;
    char c;
    cin >> w >> n;

    vector<int> kuji(w);
    REP(i, w) kuji[i] = i + 1;

    REP(i, n)
    {
        cin >> a >> c >> b;
        swap(kuji[a-1], kuji[b-1]);
    }

    REP(i, w) cout << kuji[i] << endl;
    
    return 0;
}

