#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    int w, n;
    
    cin >> w >> n;
    
    int *arr = new int(w + 1);
    
    for (int i = 0; i <= w; i++)
    {
        arr[i] = i;
    }
    
    for (int i = 0; i < n; i++)
    {
        int a, b;
        scanf("%d,%d", &a, &b);
        
        swap(arr[a], arr[b]);
    }
    for (int i = 1; i <= w; i++)
    {
        cout << arr[i] << endl;
    }
    
    return 0;
}

