#include#include #include #include using namespace std;const int maxn = 105;const int maxm = 16;const int INF = 0x3f3f3f3f;int dp[maxm][1< >T; while(T--){ cin>>N>>M>>Money; for(int i=0;i<=N;i++) for(int j=0;j<=N;j++) dist[i][j] = INF; for(int i=1;i<=N;i++) dist[i][i] = 0; for(int i=1;i<=M;i++){ int u,v,w; scanf("%d %d %d",&u,&v,&w); if(dist[u][v] > w) dist[u][v] = dist[v][u] = w; //这个地方没考虑。 } cin>>H; for(int i=0;i =0) dp[i][1< = 0 ){ dp[j][1< = 0){ flag = true; break; } } if(flag) printf("YES\n"); else printf("NO\n"); }}