#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    int n,w;
    int a,b;
    int yoko_1[100],yoko_2[100];
    int ans[100];
    
    cin>>w>>n;
    
    for (int i=0; i<n; i++) {
        cin>>a>>b;
        yoko_1[i]=a;
        yoko_2[i]=b;
    }
    
    int i=0,yoko=1,count=1;
    
    while (1) {
        if (yoko_1[i] == yoko) {
            yoko = yoko_2[i];
            i++;
        }
        else if(yoko_2[i] == yoko){
            yoko = yoko_1[i];
            i++;
        }
        else{
            i++;
        }
        if (w==i) {
            ans[yoko-1]=count;
            i=0;
            count++;
            yoko=count;
        }
        if(count>w){
            break;
        }
    }
    for (int i=0; i<w; i++) {
        cout<<ans[i]<<endl;
    }
    return 0;
}