#include <bits/stdc++.h>
std::vector<int> e[2000];
bool t[2000][2000];
int main() {
  int n, k, u, v;
  bool d[2000] = {};
  std::queue<int> q;
  std::vector<int> w;
  int r(0);
  std::scanf("%d%d", &n, &k);
  while (0 < k--) {
    std::scanf("%d%d", &u, &v);
    --u, --v;
    e[u].push_back(v);
    e[v].push_back(u);
  }
  std::scanf("%d", &k);
  while (0 < k--) {
    std::scanf("%d%d", &u, &v);
    --u, --v;
    t[u][v] = t[v][u] = true;
  }
  for (int i(0); i < n; ++i) {
    if (d[i]) continue;
    q.push(i);
    while (!q.empty()) {
      int x = q.front();
      q.pop();
      if (d[x]) continue;
      d[x] = true;
      w.push_back(x);
      for (int y : e[x]) {
        if (!d[y]) q.push(y);
      }
    }
    for (int x : w) {
      for (int y : w) {
        if (t[x][y]) goto N;
      }
    }
    r = std::max<int>(r, w.size());
  N:
    w.clear();
  }
  std::printf("%d\n", r);
  return 0;
}
