#include <bits/stdc++.h>
using namespace std;

vector<int> G[25];

int a[25], c[25];

vector<int> tmp;

void dfs1(int u) {
    a[u] = 1;
    tmp.push_back(u);
    for (int v : G[u]) {
        if (!a[v]) dfs1(v);
    }
}

long long dfs2(int i) {
    int u = tmp[i];
    bool vis[3] = {false, false, false};
    for (int v : G[u]) {
        if (~c[v]) vis[c[v]] = true;
    }
    long long res = 0;
    for (int j = 0; j < 3; ++j) {
        if (!vis[j]) {
            c[u] = j;
            if (i == (int)tmp.size() - 1) ++res;
            else res += dfs2(i + 1);
            c[u] = -1;
        }
    }
    return res;
}

int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    memset(c, -1, sizeof(c));
    for (int i = 1; i <= m; ++i) {
        int u, v;
        scanf("%d %d", &u, &v);
        G[u].push_back(v);
        G[v].push_back(u);
    }
    long long res = 1;
    for (int i = 1; i <= n; ++i) {
        if (!a[i]) {
            tmp.clear();
            dfs1(i);
            res *= dfs2(0);
        }
    }
    printf("%lld\n", res);
    return 0;
}
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;

int v[20][2];
int main() {
  int n,m;
  cin >> n >> m;
  vector<int> a(m),b(m);
  rep(i,m) cin >> a[i] >> b[i], --a[i], --b[i];
  int k;
  cin >> k;
  rep(i,k) cin >> v[i][0] >> v[i][1], --v[i][0], --v[i][1];
  int ans = 0;
  rep(x,1<<k){
    vector<bool> t(n);
    rep(i,k) t[v[i][x>>i&1]] = true;
    int res = 0;
    rep(i,m) if(t[a[i]]&&t[b[i]]) ++res;
    ans = max(ans,res);
  }
  cout << ans << endl;
}
