#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
int t,s,n,q[10001][101]={0},ji=1;
int s1[101][3],used[100]={0};
int n1[10000][2],answer=0;
int main()
{
freopen ("ski.in","r",stdin);
freopen ("ski.out","w",stdout);
cin>>t>>s>>n;
for (int i=1;i<=s;i++)
{
int a,b,c;
cin>>a>>b>>c;
s1[i][0]=a;
s1[i][1]=a+b;
s1[i][2]=c;
}
used[1]=1;
for (int i=1;i<=n;i++)
{
cin>>n1[i][0]>>n1[i][1];
}
int i=1;
for (i=1;i<=t;i++)
{
for (int j=1;j<=ji;j++)
{
for (int k=1;k<=n;k++)
{
if (n1[k][0]<=j&&i-n1[k][1]>=0)
{
q[i][j]=max(q[i][j],q[i-n1[k][1]][j]+1);
}
}
for (int k=1;k<=s;k++)
{
if (s1[k][1]==i)
{
q[i][s1[k][2]]=max(q[i][s1[k][2]],q[s1[k][0]][j]);
if (s1[k][2]>ji)
ji=s1[k][2];
}
}
if (q[i][j]>answer)
answer=q[i][j];
}
}
cout<<answer;
return 0;
}