#include <bits/stdc++.h>
using namespace std;
int Abs(int x) {
  if (x < 0) return -x;
  return x;
}
int N, M, K;
bool no[2001][2001] = {false}, visited[2001] = {false}, rooted[2001] = {false},
     notgo[2001];
vector<int> G[2001], g[2001];
int cn = 0;
bool run = true;
void dfs(int r) {
  if (!run) return;
  cn++;
  visited[r] = true;
  rooted[r] = true;
  for (int i = 0; i < g[r].size(); i++) {
    notgo[g[r][i]] = true;
  }
  for (int i = 0; i < G[r].size(); i++) {
    if (notgo[G[r][i]]) run = false;
    if (!visited[G[r][i]]) dfs(G[r][i]);
  }
}
int main() {
  scanf("%d", &N);
  scanf("%d", &M);
  for (int i = 0; i < M; i++) {
    int v, u;
    scanf("%d%d", &v, &u);
    G[v].push_back(u);
    G[u].push_back(v);
  }
  scanf("%d", &K);
  for (int i = 0; i < K; i++) {
    int v, u;
    scanf("%d%d", &v, &u);
    g[v].push_back(u);
    g[u].push_back(v);
  }
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    cn = 0;
    run = true;
    memset(visited, false, sizeof(visited));
    memset(notgo, false, sizeof(notgo));
    dfs(i);
    if (run) ans = max(ans, cn);
  }
  cout << ans;
  return 0;
}
