https://www.luogu.org/problemnew/show/P1144
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
using namespace std;
const int MAXN=1000005;
const int MAXM=4000005;
const int inf=1000000000;
const int MOD=100003;
int n,m,x,y,dis[MAXN],ans[MAXN],p[MAXN],ec;
struct cyq{
int v,next;
}edge[MAXM];
queue <int> q;
bool flag[MAXN];
void add(int u, int v){
edge[++ec].v = v;
edge[ec].next = p[u];
p[u] = ec;
}
void spfa(){
while(!q.empty()){
int u=q.front();flag[u]=0;q.pop();
for(int i=p[u];i;i=edge[i].next){
int v=edge[i].v;
if(dis[v]==dis[u]+1) ans[v]=(ans[v]+ans[u])%MOD;
if(dis[v]>dis[u]+1)
{ans[v]=ans[u];flag[v]=1;q.push(v);dis[v]=dis[u]+1;}
}
}
}
int main(){
scanf("%d%d",&n,&m);
for(int i=1;i<=m;i++){
scanf("%d%d",&x,&y);
if(x==y) continue;
add(x,y);add(y,x);
}
q.push(1);flag[1]=1;ans[1]=1;
for(int i=2;i<=n;i++) dis[i]=inf;
spfa();
for(int i=1;i<=n;i++)
printf("%d\n",ans[i]);
return 0;
}