#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int getint()
{
	char ch;do{		ch=getchar();}while (ch!='-'&&(ch<'0'||ch>'9'));
	int ans=0,f=0;	if (ch=='-') f=1; else ans=ch-'0';
	while (isdigit(ch=getchar())) ans=ans*10+ch-'0';
	if (f) ans*=-1;
	return ans;
}
int a[2][211],b[2][21];
bool vis[211];
int main()
{
	int n,m,k,ans=0;
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	  cin>>a[0][i]>>a[1][i];
	cin>>k;
	for(int i=1;i<=k;i++)
	  cin>>b[0][i]>>b[1][i];
	for(int i=0;i<(1<<k);i++)
	{
		for(int j=0;j<k;j++)
		{
			if(i&(1<<j))
			  vis[b[0][j+1]]=1;
			else
			  vis[b[1][j+1]]=1;
		}
		int mid=0;
		for(int j=1;j<=m;j++)
		  if(vis[a[0][j]]&&vis[a[1][j]])
		    mid++;
		ans=ans>mid? ans:mid;
		for(int j=1;j<=n;j++)
		  vis[j]=0;
	}
	cout<<ans;
	return 0;
 } 
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include <queue>
#include<sstream>
#include <stack>
#include <set>
#include <bitset>
#include<vector>
#define FAST ios::sync_with_stdio(false)
#define abs(a) ((a)>=0?(a):-(a))
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mem(a,b) memset(a,b,sizeof(a))
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define rep(i,a,n) for(int i=a;i<=n;++i)
#define per(i,n,a) for(int i=n;i>=a;--i)
#define endl '\n'
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PII;
const int maxn = 1e5+200;
const int inf=0x3f3f3f3f;
const double eps = 1e-7;
const double pi=acos(-1.0);
const int mod = 1e9+7;
inline int lowbit(int x){return x&(-x);}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
void ex_gcd(ll a,ll b,ll &d,ll &x,ll &y){if(!b){d=a,x=1,y=0;}else{ex_gcd(b,a%b,d,y,x);y-=x*(a/b);}}//x=(x%(b/d)+(b/d))%(b/d);
inline ll qpow(ll a,ll b,ll MOD=mod){ll res=1;a%=MOD;while(b>0){if(b&1)res=res*a%MOD;a=a*a%MOD;b>>=1;}return res;}
inline ll inv(ll x,ll p){return qpow(x,p-2,p);}
inline ll Jos(ll n,ll k,ll s=1){ll res=0;rep(i,1,n+1) res=(res+k)%i;return (res+s)%n;}
inline ll read(){ ll f = 1; ll x = 0;char ch = getchar();while(ch>'9'||ch<'0') {if(ch=='-') f=-1; ch = getchar();}while(ch>='0'&&ch<='9') x = (x<<3) + (x<<1) + ch - '0',  ch = getchar();return x*f; }
int dir[4][2] = { {1,0}, {-1,0},{0,1},{0,-1} };

ll ok[maxn];
typedef struct All
{
    ll A;
    ll B;
}all;

all a[maxn];
ll each[maxn][2];
ll k, n, m;
ll ma = 0;

void dfs(int pos)
{
    if(pos>k)
    {
        ll cnt = 0;
        rep(i,1,m) if(ok[a[i].A]&&ok[a[i].B]) cnt++;
        ma = max(cnt,ma);
        return;
    }
    ok[each[pos][0]] ++;
    dfs(pos+1);
    ok[each[pos][0]] --;

    ok[each[pos][1]] ++;
    dfs(pos+1);
    ok[each[pos][1]] --;
}

int main()
{
    n = read(), m = read();
    rep(i,1,m) a[i].A = read(), a[i].B = read();
    k = read();
    rep(i,1,k) each[i][0] = read(), each[i][1] = read();
    dfs(1);
    cout<<ma<<endl;
    return 0;
}
