#include<bits/stdc++.h>
using namespace std;
int head[4000005],num_edge;
struct Edge
{
int nxt,to;
}edge[4000005];
void add_edge (int from,int to)
{
edge[++num_edge].nxt=head[from];
edge[num_edge].to=to;
head[from]=num_edge;
}
typedef pair<int,int> pii;
int vis[4000005], d[4000005],ans[4000005];
void dijkstra(int s)
{
ans[s]=1;
priority_queue<pii, vector<pii>, greater<pii> > Q;
memset(vis, false, sizeof(vis));
Q.push(make_pair(d[s], s));
while(!Q.empty())
{
pii tmp = Q.top();
Q.pop();
int x = tmp.second;
if(vis[x]) continue;
vis[x] = true;
for(int i = head[x]; i>0; i = edge[i].nxt)
{
int j=edge[i].to;
if(d[j]==d[x]+1)
{
ans[j]+=ans[x];
ans[j]%=100003;
}
if(d[j]>d[x]+1)
{
ans[j]=ans[x];
d[j]=d[x]+1;
Q.push(make_pair(d[edge[i].to], edge[i].to));
}
}
}
}
int main ()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n,m;
cin>>n>>m;
for(int i=1; i<=n; i++)
{
d[i]=0x3f3f3f3f;
}
for (int i=1;i<=m;i++)
{
int u,v;
cin>>u>>v;
add_edge(u,v);
add_edge(v,u);
}
dijkstra(1);
for (int i=1;i<=n;i++)
{
cout<<ans[i]<<endl;
}
return 0;
}