#include<bits/stdc++.h> usingnamespace std; int n,m; int g[205][205]; int minsize=INT_MAX; //初始化为INT_MAX int minid=0; intmain() { cin>>n>>m; int cnt=0; memset(g,0,sizeof(g)); for (int i = 0; i <m ; ++i) { int a,b,c; cin>>a>>b>>c; g[a][b]=c; g[b][a]=c; } int time; cin>>time; for (int j = 0; j <time ; ++j) { int k; cin>>k; int roll[k+5]; int has[k+5]; memset(has,0,sizeof(has)); roll[0]=roll[k+1]=0; //起点和终点必定是家 for (int i = 1; i <=k ; ++i) { cin>>roll[i]; if(has[roll[i]]) has[0]=1; //每个打卡点仅能打卡一次 else has[roll[i]]=1; } int flag=1; int tmpsize=0; if(k!=n||has[0]) continue; for (int l = 1; l <=k+1 ; ++l) { if(g[roll[l-1]][roll[l]]==0) { flag=0; break; } tmpsize+=g[roll[l-1]][roll[l]]; } if(flag==1) { if(tmpsize<minsize){ minsize=tmpsize; minid=j+1;