#include <bits/stdc++.h>
using namespace std;
bool link[2001][2001], ulink[2001][2001];
bool visited[2001];
int n, k, m;
vector<int> data;
void dfs(int st) {
  for (int i = 1; i <= n; i++) {
    if (!visited[i] && link[st][i]) {
      visited[i] = 1;
      data.push_back(i);
      dfs(i);
    }
  }
}
int stop;
int main() {
  while (scanf(" %d", &n) == 1) {
    memset(link, 0, sizeof(link));
    memset(ulink, 0, sizeof(ulink));
    scanf(" %d", &m);
    for (int i = 0; i < m; i++) {
      int a, b;
      scanf(" %d %d", &a, &b);
      link[a][b] = link[b][a] = 1;
    }
    scanf(" %d", &k);
    for (int i = 0; i < k; i++) {
      int a, b;
      scanf(" %d %d", &a, &b);
      ulink[a][b] = ulink[b][a] = 1;
    }
    int ans = 0;
    memset(visited, 0, sizeof(visited));
    for (int i = 1; i <= n; i++) {
      if (!visited[i]) {
        data.clear();
        visited[i] = 1;
        data.push_back(i);
        dfs(i);
        bool flag = true;
        for (int j = 0; j < data.size(); j++) {
          for (int k = j + 1; k < data.size(); k++) {
            if (ulink[data[j]][data[k]]) {
              flag = false;
              j = data.size();
              break;
            }
          }
        }
        if (flag && data.size() > ans) ans = data.size();
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
