#include <bits/stdc++.h>
using namespace std;
const int MAXN = (int)(1e5 + 123);
vector<int> gg[MAXN], gb[MAXN];
bool was[MAXN], been[MAXN];
int cnt = 0;
void dfs(int v) {
  cnt++;
  was[v] = been[v] = true;
  for (auto to : gg[v]) {
    if (was[to]) continue;
    dfs(to);
  }
}
int main() {
  int n;
  cin >> n;
  int good;
  cin >> good;
  for (int i = 1; i <= good; i++) {
    int a, b;
    cin >> a >> b;
    gg[a].push_back(b);
    gg[b].push_back(a);
  }
  int bad;
  cin >> bad;
  for (int i = 1; i <= bad; i++) {
    int a, b;
    cin >> a >> b;
    gb[a].push_back(b);
    gb[b].push_back(a);
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (was[i]) continue;
    cnt = 0;
    dfs(i);
    bool no = false;
    for (int j = 1; j <= n; j++) {
      if (been[j]) {
        for (auto to : gb[j])
          if (been[to]) {
            no = true;
            break;
          }
      }
      if (no) break;
    }
    if (!no) ans = max(ans, cnt);
    for (int j = 1; j <= n; j++) been[j] = false;
  }
  cout << ans << endl;
  return 0;
}
