#include using namespace std; const int N = 4e5 + 10; const int MOD = 100003; int h[N], ne[N], e[N], idx; void add(int a, int b) { e[idx] = b, ne[idx] = h[a], h[a] = idx++; } int cnt[N]; //从顶点1开始,到其他每个点的最短路有几条 int dist[N]; //最短距离 int n, m; void bfs() { memset(dist, 0x3f, sizeof dist); queue q; q.push(1); cnt[1] = 1; //从顶点1开始,到顶点1的最短路有1条 dist[1] = 0; //距离为0 while (q.size()) { int u = q.front(); q.pop(); for (int i = h[u]; ~i; i = ne[i]) { int j = e[i]; if (dist[j] > dist[u] + 1) { dist[j] = dist[u] + 1; q.push(j); cnt[j] = cnt[u]; } else if (dist[j] == dist[u] + 1) cnt[j] = (cnt[j] + cnt[u]) % MOD; } } } int main() { memset(h, -1, sizeof h); scanf("%d %d", &n, &m); while (m--) { int a, b; scanf("%d %d", &a, &b); add(a, b), add(b, a); } bfs(); for (int i = 1; i <= n; i++) printf("%d\n", cnt[i]); return 0; }