#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9;
const int mod = inf + 7;
const double eps = 1e-9;
const double pi = acos(-1.0);
int n, k, m, used[2020][2020];
vector<int> g[2020];
bool c[2020];
vector<int> cur;
void dfs(int v) {
  c[v] = 1;
  cur.push_back(v);
  for (__typeof(g[v].begin()) it = g[v].begin(); it != g[v].end(); it++) {
    int to = *it;
    if (!c[to]) dfs(to);
  }
}
int main() {
  scanf("%d\n", &n);
  scanf("%d\n", &k);
  for (int i = 0, x, y; i < k; i++) {
    scanf("%d%d", &x, &y);
    x--;
    y--;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  scanf("%d\n", &m);
  for (int i = 0, x, y; i < m; i++) {
    scanf("%d%d\n", &x, &y);
    x--;
    y--;
    used[x][y] = used[y][x] = 1;
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (!c[i]) {
      cur.clear();
      dfs(i);
      bool ok = 1;
      for (int i = 0; i < cur.size(); i++) {
        for (int j = 0; j < cur.size(); j++) {
          if (used[cur[i]][cur[j]]) ok = 0;
        }
      }
      if (ok) ans = max(ans, (int)cur.size());
    }
  }
  printf("%d\n", ans);
  return 0;
}
