#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59

int arr[32];
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int w, n;
    cin >> w >> n;
    for (int i = 1; i <= 30; ++i)
        arr[i] = i;

    for (int i = 1; i <= n; ++i)
    {
        int a, b;
        char c;
        cin >> a >> c >> b;
        //cout << a << " " << b << endl;
        swap(arr[a], arr[b]);
    }

    for (int i = 1; i <= w; ++i)
    {
        cout << arr[i] << endl;
    }

    return 0;
}
