#include <bits/stdc++.h>
#if __has_include(<atcoder/all>)
    #include <atcoder/all>
    using namespace atcoder;
#endif

using namespace std;
using Graph = vector<vector<int>>;
using vst= vector<string>;
using vin= vector<int>;
using ll=long long;
using ull=unsigned long long;
using vll= vector<ll>;
using P=pair<int ,int>;
//const long double pi=acos(-1);
#define ft first
#define sd second
#define fn front
#define pb push_back
#define eb emplace_back
#define it insert
#define vvi vector<vector<int>>
#define si(v) int((v).size())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rell(i,n) for (ll i=0; i< (ll)(n); i++)
#define sot(x) sort(x.begin(), x.end())
#define rese(x) reverse(x.begin(), x.end())
#define gsot(x) sort(x.begin(), x.end(), greater<ll>());
#define vnn(x,y,s,name) vector<vector<int>> name(x, vector<int>(y,s))
#define mse(x) memset(x, 0, sizeof(x)
#define all(x) (x).begin(),(x).end()
#define mii(x,y,z) min(x,min(y,z))
#define maa(x,y,z) max(x,max(y,z))
#define cps CLOCKS_PER_SEC
#define yes cout<<"Yes"<<"\n"
#define no cout<<"No"<<"\n"
#define cset(x) cout<<fixed<<setprecision(x)
//const int INF=1001001001;
//998244353  1000000007


int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,m;
   cin>>n>>m;
   vector<P> a(m);
   rep(i,m){
       cin>>a[i].ft>>a[i].sd;
       a[i].ft--; a[i].sd--;
   }
   int k;
   cin>>k;
   vector<P> c(k);
   rep(i,k){
       cin>>c[i].ft>>c[i].sd;
       c[i].ft--; c[i].sd--;
   }
   int ans=0;
   int l=(1<<17);
   rep(i,l){
       bitset<17> s(i);
       vector<bool> d(n,0);
       rep(j,k){
           if(s[j]) d[c[j].ft]=true;
           else d[c[j].sd]=true;
       }
       int cnt=0;
       rep(j,m){
           if(d[a[j].ft]&&d[a[j].sd]) cnt++;
       }
       if(cnt>ans) ans=cnt;
   }
   //cout<<l<<endl;
   cout<<ans<<endl;
}



















#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include<set>
#define ll long long
using namespace std;

int main(){
    int n,m;
    cin>>n>>m;
    vector<int> a(m),b(m);
    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i];
    }
    int k;
    cin>>k;
    vector<int> c(k),d(k);
    for(int i=0;i<k;i++){
        cin>>c[i]>>d[i];
    }
    int ans=0;
    for(int bit=0;bit<(1<<k);bit++){
        vector<bool> v(n,false);
        for(int i=0;i<k;i++){
            if(bit & (1<<i)){
                v[c[i]]=true;
            }else{
                v[d[i]]=true;
            }
        }
        int cnt=0;
        for(int i=0;i<m;i++){
            if(v[a[i]]==true && v[b[i]]==true) cnt++;
        }
        ans=max(ans,cnt);
    }
    cout<<ans<<endl;
    return 0;
}