#include <bits/stdc++.h>
using namespace std;
bool F[2001][2001];
bool D[2001][2001];
int C[2001];
vector<int> V[2001];
int n;
void f(int v, int c) {
  if (C[v]) return;
  C[v] = c;
  V[c].push_back(v);
  for (int i = 1; i <= n; ++i)
    if (F[v][i]) f(i, c);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  int k;
  cin >> k;
  while (k--) {
    int a, b;
    cin >> a >> b;
    F[a][b] = 1;
    F[b][a] = 1;
  }
  cin >> k;
  while (k--) {
    int a, b;
    cin >> a >> b;
    D[a][b] = 1;
    D[b][a] = 1;
  }
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    f(i, i);
    int t = V[i].size();
    for (int j = 0; j < t; ++j)
      for (int l = 0; l < t; ++l)
        if (D[V[i][j]][V[i][l]]) goto skip;
    ans = max(ans, t);
  skip:;
  }
  cout << ans << endl;
  return 0;
}
