#include<bits/stdc++.h>
using namespace std;
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define p pair<long long,long long>
#define endl '\n' 
#define iof  freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define pi acos(-1)
int fx[]={0,0,1,-1,1,1,-1,-1};
int fy[]={1,-1,0,0,-1,1,-1,1};
const int mxn=1e9+7;

int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
    int n;
    cin>>n;
    int m;
    cin>>m;
    vector<p>vp(m);
    for(auto &i:vp)
    {
        cin>>i.first>>i.second;
    }
    int k;
    cin>>k;
    vector<p>vk(k);
    for(auto &i:vk)
    {
        cin>>i.first>>i.second;
    }
    int mx=0;
    for(int mask=0;mask<(1<<k);mask++)
    {
        map<int,int>mp;
        for(int i=0;i<k;i++)
        {
            if((1<<i)&mask)mp[vk[i].first]++;
            else mp[vk[i].second]++;
        }
        int ans=0;
        for(auto i:vp)
        {
            if(mp[i.first]&&mp[i.second])ans++;
        }
        mx=max(mx,ans);
    }
    cout<<mx<<endl;
}
#include <bits/stdc++.h>

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
#define RSort(a) sort(a.rbegin(), a.rend())
#define Output(a) cout << a << endl

typedef long long int ll;
typedef vector<int> vi;
typedef vector<long long> vll;

const int INF = 1<<30;
const ll MOD = 1000000007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

string to2(int bina, int k){
    int ans = 0;
    for(int i = 0; bina > 0; i++){
        ans = ans + (bina % 2) * pow(10, i);
        bina /= 2;
    }
    string result = to_string(ans);
    while(result.size() < k){
        result = "0" + result;
    }
    return result;
}

int main(){
    ll n, m; cin >> n >> m;
    vll a(m), b(m);
    rep(i, m) cin >> a[i] >> b[i];
    ll k; cin >> k;
    vll c(k), d(k);
    rep(i, k) cin >> c[i] >> d[i];
    ll ans = 0;

    rep(bit, (1<<k)){
        vll s;

        rep(i, k){
            if(bit & 1 << i){
                s.push_back(1);
            }else{
                s.push_back(0);
            }
        }

        vll t(n);
        rep(i, (int)s.size()){
            if(s[i]){
                t[c[i]-1] = 1;
            }else{
                t[d[i]-1] = 1; 
            }
        }

        ll com = 0;
        rep(i, m){
            if(t[a[i]-1] == 1 and t[b[i]-1] == 1) com++;
        }
        ans = max(com, ans);
    }
    cout << ans << endl;
    return 0;
}