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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl;
typedef long long ll;
typedef unsigned long long ull;

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

    rep(i, n)
    {
        int b, d;
        char c;
        cin >> b >> c >> d;
        int s = a[d];
        a[d] = a[b];
        a[b] = s;
    }

    for (int i = 1; i <= w; i++)
    {
        OP(a[i])
    }

    return 0;
}
