#include<bits/stdc++.h>
using namespace std;
int a[102],b[102];
int c[20],d[20];
int ans = 0;
void solve(int n,int m,bool flag[],int k,int l){
  if(l>=k){
    int cnt = 0;
    for(int i=0;i<m;i++)
    {
      if(flag[a[i]] == true && flag[b[i]] == true)
       cnt++;
    }
   ans = max(ans,cnt);  
   return ;
  }	
  bool temp =flag[c[l]];
    flag[c[l]] = true;
    solve(n,m,flag,k,l+1); 
    flag[c[l]] = temp;
  temp = flag[d[l]];
    flag[d[l]] = true;
    solve(n,m,flag,k,l+1);
  	flag[d[l]] = temp;
}
int main(){
int n,m;
  cin >> n >> m;
  for(int i=0;i<m;i++)
    cin >> a[i] >> b[i];
  int k;
  cin >> k;
  for(int i=0;i<k;i++)
  {
    cin >> c[i] >> d[i];
  }
  bool flag[105] = {false,};
  solve(n,m,flag,k,0);
  cout<<ans<<endl;
  
}
#include <bits/stdc++.h>          
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repp(i, st, en) for (ll i = (ll)st; i < (ll)(en); i++)
#define repm(i, st, en) for (ll i = (ll)st; i >= (ll)(en); i--)
#define all(v) v.begin(), v.end()
void chmax(ll &x, ll y) {x = max(x,y);}
void chmin(ll &x, ll y) {x = min(x,y);}

int main() {
    ll N, M; cin >> N >> M;
    vector<pair<ll,ll>> m(M);
    rep(i,M) {
        ll a, b; cin >> a >> b;
        a--; b--;
        m[i] = {a,b};
    }
    ll K; cin >> K;
    vector<pair<ll,ll>> k(K);
    rep(i,K) {
        ll c, d; cin >> c >> d;
        c--; d--;
        k[i] = {c,d};
    }

    ll ans = 0;
    rep(bit,1<<K) {
        vector<ll> vec(N);
        rep(i,K) {
            ll x = k[i].first, y = k[i].second;
            if ((bit>>i)&1) vec[x]++;
            else vec[y]++;
        }
        ll cnt = 0;
        rep(i,M) {
            ll x = m[i].first, y = m[i].second;
            if (vec[x]>=1 && vec[y]>=1) cnt++;
        }
        ans = max(ans,cnt);
    }

    cout << ans << endl;
}