#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define pb push_back
using namespace std;
const int N = 1e6 + 5;
const int MOD = 1e9 + 7;
int n, m, ans1, k;
vector<pair<int, int> > v, vv;
vector<int> ans;

int solve(int i){
    if(i >= k){
        int ok = 0;
        unordered_map<int, int> mp;
        for(auto k : ans)
            mp[k]++;
        for(int i = 0; i < m; ++i){
            int a = v[i].first, b = v[i].second;
            if(mp[a] and mp[b])
                ++ok;
            ans1 = max(ans1, ok);
        }
        return ok;
    }
    long long int a = vv[i].first, b = vv[i].second, cur = 0;
    ans.push_back(a);
    cur += solve(i + 1);
    ans.pop_back();
    ans.push_back(b);
    cur += solve(i + 1);
    ans.pop_back();
    return cur;
}

int main(){
    fast;
    cin >> n >> m;
    for(int i = 0; i < m; ++i){
        int a, b;
        cin >> a >> b;
        v.push_back({a, b});
    }
    cin >> k;
    for(int i = 0; i < k; ++i){
        int a, b;
        cin >> a >> b;
        vv.push_back({a, b});
    }
    solve(0);
    cout << ans1 << '\n';
    return 0;
}
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,m,a[110],b[110],c[110],x[110],y[110],k,ans;
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++) scanf("%d%d",&a[i],&b[i]);
    scanf("%d",&k);
    for(int i=1;i<=k;i++) scanf("%d%d",&x[i],&y[i]);
    for(int i=0;i<=(1<<k)-1;i++)
    {
        int p=i;//printf("\n%d\n",p);
        memset(c,0,sizeof(c));
        for(int j=1;j<=k;j++)
        {
            //printf("%d",p&1);
            if(p&1) c[x[j]]++;
            else c[y[j]]++;
            p>>=1; 
            
        }
        int cnt=0;
        for(int j=1;j<=m;j++) if(c[a[j]]&&c[b[j]]) cnt++;
        ans=max(ans,cnt);
    }
    printf("%d\n",ans);
    return 0;
}