#include using namespace std; const int mod=998244353; int test,n,m,x,y,z,ct,ord[1111],ans,dp[1111]; long long dist[1111]; vector > g[1111]; void dijk(int s) { priority_queue > pq; for (int i=1;i<=n;i++) dist[i]=1e18; dist[s]=0; pq.push(make_pair(0,s));ct=0; while(!pq.empty()) { int x=pq.top().second;long long y=-pq.top().first;pq.pop(); if (dist[x]!=y) continue; ord[++ct]=x; for (int i=0;idist[x]+val) { dist[to]=dist[x]+val; pq.push(make_pair(-dist[to],to)); } } } dp[s]=0; for (int i=2;i<=n;i++) { dp[ord[i]]=1e9; for (int j=0;j