#include <iostream>

using namespace std;

int main()
{
    int w, n;
    char comma;
    int ab[31][2];
    int ans[31];
    
    cin >> w >> n;
    for (int i = 0; i < n; i++)
        cin >> ab[i][0] >> comma >> ab[i][1];

    for (int i = 1; i <= w; i++) {
        int state = i;
        int pos = 0;
        for (int j = 0; j < n; j++) {
            if (pos == 0) {
                if (ab[j][0] == state) {
                    state = ab[j][1];
                    pos = 1;
                }
                else if (ab[j][1] == state) {
                    state = ab[j][0];
                    pos = -1;
                }
            }
            else if (pos == -1 && ab[j][0] == state) {
                state = ab[j][1];
                pos = 1;
            }
            else if (pos == 1 && ab[j][1] == state) {
                state = ab[j][0];
                pos = -1;
            }
        }
        ans[state] = i;
    }

    for (int i = 1; i <= w; i++)
        cout << ans[i] << "\n";

    return 0;
}