#include
#include
using namespace std;
struct node{
int v,weight;
node(int t,int w){v=t;weight=w;}
};
class Graph{
private: int MAX_V;
vector *edge;
public: Graph(int mv){
MAX_V = mv;
edge = new vector[mv+1];
}
~Graph(){
this->clear();
delete edge;
}
void clear(){
for(int i=0;i<=MAX_V;++i)
edge[i].clear();
MAX_V = 0;
}
void get_graph(){
int u,v,w;
while(~scanf("%d%d%d",&u,&v,&w))
edge[u].push_back(node(v,w));
}
void show_for_test(){
for(int i=0;i<=10;++i){
printf("%d->",i);
int len = edge[i].size();
for(int j=0;j