#include <bits/stdc++.h>
using namespace std;
#define fo(a,b,c) for(int a=b;a<=c;a++)
#define of(a,b,c) for(int a=b;a>=c;a--)
const int N=5e4+10;
const int MINN=-0x3f3f3f3f;
struct Node1{
int a,b;
}pl1[N];
struct Node2{
int a,b;
}pl2[N];
bool cmp1(Node1 x,Node1 y){
return x.a<y.a;
}
bool cmp2(Node2 x,Node2 y){
return x.a<y.a;
}
priority_queue<int,vector<int>,greater<int> > Q1;
priority_queue<int,vector<int>,greater<int> > Q2;
inline int read(){
int s=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9'){
if(ch=='-'){
f=-1;
break;
}
ch=getchar();
}
while(ch>='0'&&ch<='9'){
int u=ch^48;
s=(s<<3)+(s<<1)+u;
ch=getchar();
}
return s*f;
}
signed main(){
int n;
n=read();
int m1,m2;
m1=read();
m2=read();
fo(i,1,m1){
pl1[i].a=read();
pl1[i].b=read();
}
fo(i,1,m2){
pl2[i].a=read();
pl2[i].b=read();
}
int maxn=MINN;
fo(i,0,n){
stable_sort(pl1+1,pl1+m1+1,cmp1);
int c1=i;
int s1=0;
int ans1=0;
while(Q1.size()){
Q1.pop();
}
fo(j,1,m1){
int u=Q1.top();
while(Q1.size()&&pl1[j].a>=u){
Q1.pop();
u=Q1.top();
--s1;
}
if(s1==c1){
continue;
}
Q1.push(pl1[j].b);
++s1;
++ans1;
}
stable_sort(pl2+1,pl2+m2+1,cmp2);
int c2=n-i;
int s2=0;
int ans2=0;
while(Q2.size()){
Q2.pop();
}
fo(j,1,m2){
int u=Q2.top();
while(Q2.size()&&pl2[j].a>=u){
Q2.pop();
u=Q2.top();
--s2;
}
if(s2==c2){
continue;
}
Q2.push(pl2[j].b);
++s2;
++ans2;
}
int sum=ans1+ans2;
if(sum>maxn){
maxn=sum;
}
}
cout<<maxn<<endl;
return 0;
}