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

int main()
{
    vector<int> bar;
    int n, w;
    char sp;
    int a[2];
    cin >> w;
    for(int c =1; c <= w; c++)
        bar.push_back(c);
    cin >> n;
    for(int c =0; c < n; c++)
    {
        cin >> a[0] >> sp  >> a[1];
        swap(bar[a[0] -1],bar[a[1] -1]);
    }
    for(int c=0; c < w; c++)
        cout << bar[c] << endl;
    return EXIT_SUCCESS;
}