#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;


std::vector<std::string> split(std::string str, char del) {
    int first = 0;
    int last = str.find_first_of(del);
 
    std::vector<std::string> result;
 
    while (first < str.size()) {
        std::string subStr(str, first, last - first);
 
        result.push_back(subStr);
 
        first = last + 1;
        last = str.find_first_of(del, first);
 
        if (last == std::string::npos) {
            last = str.size();
        }
    }
 
    return result;
}

int main(){
    int w,n;
    cin >> w >> n;
    vector<int> N(w);
    for(int i=0; i<w; i++) N[i]=i;
    // rep(i,w) cout << N[i]; cout << endl;
    // cout << endl;
    rep(i,n){
        string s;
        cin >> s;
        vector<string> A = split(s, ',');
        string a = A[0], b = A[1];
        // cout << a << " " <<b << endl;
        int tmp=N[stoi(a)-1];
        N[stoi(a)-1]=N[stoi(b)-1];
        N[stoi(b)-1]=tmp;

    }
    rep(i,w) cout << N[i]+1 << endl;
    return 0;
}
