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

vector<int> makeRangeArray(int n)
{
        static vector<int> vec;
        for(int i = 1; i <= n; i++){
                vec.push_back(i);
        }

        return vec;
}

void exchangeInArray(vector<int>& vec, int a, int b)
{
        if(a <= 0 || b <= 0)
                throw "エラー発生";

        a--;
        b--;

        swap(vec[a],vec[b]);
}

int reader(string str, int& a, int& b)
{
        int i;

        a = 0;
        b = 0;
        for(i=0; str[i] != ','; i++)
        {
                a *= 10;
                a += str[i] - '0';
        }

        for(i++; str[i];i++){
                b *=10;
                b += str[i] - '0';
        }
}

int main()
{
        try{
                int w;
                int n;
                cin >> n;
                cin >> w;
                vector<int> vec = makeRangeArray(n);
                for(int i=0;i<w;i++){
                        int a,b;
                        string str;
                        cin >> str;
                        reader(str, a, b);
                        exchangeInArray(vec, a, b);
                }

                for(auto x:vec){
                        cout << x << endl;
                }
        }
        catch (char *str){
                cout << str << endl;
        }
}