#include<bits/stdc++.h>
using namespace std;
struct Edge{
int v,to;
}e[4000005];
int n,m,tot,head[1000005],dp[1000005],d[1000005];
bool vis[1000005];
const int INF=0x3f3f3f3f,mod=100003;
void bfs1()
{
queue<int>q;
q.push(1);
d[1]=1;
while(!q.empty())
{
int t=q.front();q.pop();
for(int i=head[t];i;i=e[i].to)
{
int v=e[i].v;
if(!d[v])
{
d[v]=d[t]+1;
q.push(v);
}
}
}
}
void bfs2()
{
queue<int>q;
q.push(1);
dp[1]=1;
while(!q.empty())
{
int t=q.front();q.pop();
for(int i=head[t];i;i=e[i].to)
{
int v=e[i].v;
if(d[v]==d[t]+1)
{
if(dp[v]==0)q.push(v);
dp[v]+=dp[t];dp[v]%=mod;
}
}
}
}
void addedge(int u,int v)
{
tot++;
e[tot].v=v;
e[tot].to=head[u];
head[u]=tot;
}
signed main()
{
cin.tie(0)->sync_with_stdio(0);
cin>>n>>m;
for(int i=1;i<=m;i++)
{
int u,v;cin>>u>>v;
addedge(u,v);
addedge(v,u);
}
bfs1();bfs2();
for(int i=1;i<=n;i++)
cout<<dp[i]<<'\n';
return 0;
}