#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e4 + 4;
vector<int> fri[MAXN];
int id[MAXN], cnt[MAXN], idx, ans;
bool vis[MAXN], dis[MAXN][MAXN];
void dfs(int u) {
  vis[u] = true;
  id[u] = idx;
  cnt[idx]++;
  for (int v : fri[u]) {
    if (!vis[v]) {
      dfs(v);
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cout << setprecision(10) << fixed;
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < k; ++i) {
    int u, v;
    cin >> u >> v;
    fri[u].push_back(v);
    fri[v].push_back(u);
  }
  cin >> k;
  for (int i = 0; i < k; ++i) {
    int u, v;
    cin >> u >> v;
    dis[u][v] = true;
  }
  for (int i = 1; i <= n; ++i) {
    if (!vis[i]) {
      idx++;
      dfs(i);
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      if (i == j) continue;
      if (id[i] == id[j] && dis[i][j]) {
        cnt[id[i]] = 0;
      }
    }
  }
  for (int i = 1; i <= idx; ++i) {
    ans = max(ans, cnt[i]);
  }
  cout << ans;
  return 0;
}
