#include<bits/stdc++.h>
#define ll long long
//define LOCAL
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
using namespace std;
const int MOD=100003;
const int INF=0x3f3f3f3f;
int main()
{
int n,m;
cin>>n>>m;
vector<vector<int>> g(n);
REP(i,m)
{
int u,v;
cin>>u>>v;
--u;--v;
if(u==v)continue;
g[u].push_back(v);
g[v].push_back(u);
}
vector<int> dist(n,INF);
vector<int> num(n,0);
num[0]=1;
dist[0]=0;
queue<int> q;
q.push(0);
while(!q.empty())
{
int u=q.front();
q.pop();
for(int v:g[u])
{
if(dist[v]==INF)
{
dist[v]=dist[u]+1;
num[v]=num[u];
q.push(v);
}
else{
if(dist[v]==dist[u]+1)
{
num[v]=(num[v]+num[u])%MOD;
}
}
}
}
REP(i,n)cout<<num[i]<<endl;
return 0;
}
第6个点TLE,求指教