#include<iostream>
#include<cstring>
#include<queue>
using namespace std;
#define N 1010
#define M 100010
struct graph{
int tot,head[M];
struct edge{
int next;
int to,dis;
}ed[M];
void addEdge(int from,int to,int dis){
ed[++tot].next=head[from];
ed[tot].to=to,ed[tot].dis=dis;
head[from]=tot;
}
void init(){
tot=0;
memset(ed,-1,sizeof(ed));
memset(head,-1,sizeof(head));
}
}l;
queue<int>q;
int d[N],cntTimes[N];
bool vis[N];
int n,m1,m2,x,y,w;
int spfa(){
memset(d,0x7f,sizeof(d));
q.push(1);
d[1]=0;
while(!q.empty()){
int v=q.front();
q.pop();
vis[v]=0,cntTimes[v]++;
for(int i=l.head[v];i;i=l.ed[i].next){
int u=l.ed[i].to,dis=l.ed[i].dis;
if(d[v]+dis<d[u]){
d[u]=d[v]+dis;
if(!vis[u]){
q.push(u);
if(cntTimes[u]>n-1)return -1;
vis[u]=1;
}
}
}
}
if(d[n]>2e8)return -2;
return d[n];
}
int main(){
cin>>n>>m1>>m2;
for(int i=1;i<=m1;i++){
cin>>x>>y>>w;
l.addEdge(x,y,w);
}
for(int i=1;i<=m2;i++){
cin>>x>>y>>w;
l.addEdge(y,x,-w);
}
for(int i=1;i<n;i++)l.addEdge(i+1,i,0);
cout<<spfa();
return 0;
}