#include <iostream>
#include<stdio.h>
#define for1(be,end,z) for(z=be;z<end;z++)
#define for2(end,z) for1(0,end,z)

using namespace std;
int g_lost[30];
/*void init()
{
    int i;
    for2(30,i)
    {
        g_lost[i]=i+1;
    }
}
void swap1(int a,int b)
{
    int tp;
    tp=g_lost[a-1];
    g_lost[a-1]=g_lost[b-1];
    g_lost[b-1]=tp;
}*/
int main()
{
    int w,n,i,tp;
    cin>>w>>n;
    int data[w];
    for2(w,i)
    {
        data[i]=i+1;
    }
    while(n--)
    {
        int a,b;
        scanf("%d,%d", &a, &b);
        tp=data[a-1];
        data[a-1]=data[b-1];
        data[b-1]=tp;
    }
    for2(w,i)
    {
        cout<<data[i]<<endl;
    }
    return 0;
}