#define E 1000000
#define V 1000000
struct Edge{
int v;
int c;
int next;
}p[E];
int head[V];
int e;
void clear()
{
memset(head,-1,sizeof(head));
e=0;
}
void addnote(int u,int v,int c)
{
p[e].v=v;p[e].c=c;
p[e].next=head[u];head[u]=e++;
}
#define V 1000000
struct Edge{
int v;
int c;
int next;
}p[E];
int head[V];
int e;
void clear()
{
memset(head,-1,sizeof(head));
e=0;
}
void addnote(int u,int v,int c)
{
p[e].v=v;p[e].c=c;
p[e].next=head[u];head[u]=e++;
}