#include <iostream>
#include <list>
using namespace std;
void swap(char *in,int a,int b)
{
    char tp;
    tp=in[a];
    in[a]=in[b];
    in[b]=tp;
}
int main()
{
    char *lost,a,b,p;
    int w,n,i;
    cin>>w;
    lost=new char[w];
    for (i=1;i<=w;i++)
        lost[i-1]=i+0x30;
    cin>>n;
    while(n--)
    {
        cin>>a>>p>>b;
        swap(lost,a-0x30-1,b-0x30-1);
    }
    for (i=0;i<w;i++)
    {
        cout<<lost[i]<<endl;
    }
    return 0;
}