// P1144 最短路计数。C++17;无向无权图,重边按不同边计数。 #include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, m; if (!(cin >> n >> m)) return 0; vector head(n + 1, -1), to(2 * m), nxt(2 * m); int tot = 0; auto add = [&](int u, int v) { to[tot] = v; nxt[tot] = head[u]; head[u] = tot++; }; for (int i = 0, u, v; i < m; ++i) { cin >> u >> v; add(u, v); add(v, u); } vector dist(n + 1, -1), ways(n + 1, 0); queue q; dist[1] = 0; ways[1] = 1; q.push(1); while (!q.empty()) { int u = q.front(); q.pop(); for (int e = head[u]; e != -1; e = nxt[e]) { int v = to[e]; if (dist[v] == -1) { dist[v] = dist[u] + 1; q.push(v); } if (dist[v] == dist[u] + 1) ways[v] = (ways[v] + ways[u]) % 100003; } } for (int i = 1; i <= n; ++i) cout << ways[i] << '\n'; }