#include <iostream>
#include <bits/stdc++.h>
#define For(i,x,y) for(int i=(x); i<=(y); i++)
#define fori(i,x,y) for(int i=(x); i<(y); i++)
#define rep(i,y,x) for(int i=(y); i>=(x); i--)
#define mst(x,a) memset(x,a,sizeof(x))
#define pb push_back
#define sz(a) (int)a.size()
#define mp make_pair
#define fi first
#define se second
#define debug(a) cout << #a << ": " << a << endl
using namespace std;
typedef long long ll;
typedef pair<int,int>pa;
typedef pair<ll,ll>pai;
const int N = 2e5+10;
const int M = 1e5;
int main()
{
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n, m, k;
cin>>n>>m;
vector<int>a(m),b(m);
int u, v;
for(int i = 0; i < m; i ++ ){
cin>>a[i]>>b[i];
a[i]--,b[i]--;
}
cin>>k;
vector<int>c(k),d(k);
for(int i = 0; i < k ; i ++ ){
cin>>c[i]>>d[i];
c[i]--,d[i]--;
}
int ans = 0;
for(int bitmasks =0; bitmasks< (1<<k); bitmasks ++ ){
vector<int>vis(n);
for(int i = 0; i <k; i ++ ){
if((bitmasks>>i)&1)vis[c[i]] = 1;
else vis[d[i]] = 1;
}
int sum = 0;
for(int i = 0; i < m ; i ++ ){
if(vis[a[i]]&&vis[b[i]])sum++;
}
ans= max(ans,sum);
}
cout<<ans<<'
';
return 0;
}