#include <iostream>
#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 swap(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()
{
    init();
    int w,n,i;
    cin>>w;
    cin>>n;
    while(n--)
    {
        char a,b,p;
        cin>>a>>p>>b;
        swap(a-0x30,b-0x30);
    }
    for2(w,i)
    {
        cout<<g_lost[i];
        if(i!=w)cout<<endl;
    }
    return 0;
}