#include<bits/stdc++.h>
const int maxn=55000;
inline const void read(int &a)
{
char c=getchar();int b=1;a=0;
while(c<'0'||c>'9'){if(c=='-')b=-1;c=getchar();}
while(c>='0'&&c<='9')
{
a=(a<<1)+(a<<3)+c-'0';
c=getchar();
}
a*=b;
}
inline const void write(int a)
{
if(a<0){putchar('-');a=-a;}
if(a>9)write(a/10);
putchar(a%10+'0');
}
inline const int min(int a,int b)
{
if(a<b)return a;
return b;
}
inline const int max(int a,int b)
{
if(a>b)return a;
return b;
}
int n,m,t,d=0;
int from[maxn],to[maxn],next[maxn],point[maxn],height[maxn];
inline const void add(int a,int b,int h)
{
next[++d]=point[a];
to[d]=b;
point[a]=d;
height[d]=h;
}
struct LEAST_TREE
{
int belong[maxn];
inline const int check(int a)
{
if(a==belong[a])return a;
return belong[a]=check(belong[a]);
}
struct side
{
int from,to,next,height;
inline const bool operator<(const side&b)
{
if(height<b.height)return true;
return false;
}
}s[maxn];
void solve()
{
for(int i=1;i<=n;i++)belong[i]=i;
memset(point,false,sizeof(point));
for(int i=1;i<=m;i++){read(s[i].from);read(s[i].to);read(s[i].height);}
std::sort(s+1,s+1+m);
int k=n-1,t=1;
while(k)
{
if(check(s[t].from)==check(s[t].to)){t++;continue;}
belong[check(s[t].from)]=s[t].to;
add(s[t].from,s[t].to,s[t].height);
k--;t++;
}
}
}least_tree;
int leaf[maxn],father[maxn],top[maxn],left[maxn],right[maxn];
struct LINK_CUT_TREE
{
int son[maxn];
bool vis[maxn];
inline const int dfs1(int p)
{
vis[p]=true;
int side=point[p];
while(side)
{
if(!vis[to[side]])
side=next[side];
}
}
inline const int dfs2(int p)
{
}
void solve()
{
memset(vis,false,sizeof(vis));
dfs1(1);
dfs2(1);
}
}link_cut_tree;
struct SEGMENT_TREE
{
int big[maxn],r=0;
inline const void update(int p)
{
big[p]=//max(big[p<<1],small[p<<1|1]);
}
inline const void build(int p,int l,int r)
{
if(l==r)big[p]=leaf[++r];
}
inline const void query(int p,int l,int r,int ll,int rr)
{
}
void solve()
{
while(m)
{
m--;
int start,end;
read(start);read(end);
}
}
}segment_tree;
int main()
{
read(n);read(m);read(t);
least_tree.solve();
link_cut_tree.solve();
segment_tree.solve();
return 0;
}