#include using namespace std; const long long INF=1e15; struct Edge{ int u,v,w; }; int main(){ int T; cin>>T; while(T--){ int n,m; cin>>n>>m; vectoredges; for(int i=0;i>u>>v>>w; edges.push_back({u,v,w}); } vectordist(n+1,INF); dist[1]=0; bool has_negative=false; for(int i=1;i<=n;i++){ bool updated=false; for(auto &e:edges){ if(dist[e.u]!=INF&&dist[e.u]+e.w