#include <bits/stdc++.h>
using namespace std;
int n, k, m;
std::vector<int> visited(10000, 0);
int ans = 0, temp = 0;
std::vector<pair<int, int>> g[10000];
void dfs(int v) {
  visited[v] = 1;
  temp++;
  for (auto i : g[v]) {
    if ((i.second == 1 && visited[i.first] == 2) ||
        (i.second == 2 && visited[i.first] == 1)) {
      temp = 0;
      return;
    } else if (visited[i.first] == 0) {
      if (i.second == 2) {
        visited[i.first] = 2;
      } else
        dfs(i.first);
    }
  }
}
int main() {
  cin >> n;
  cin >> k;
  int u, v;
  for (int i = 0; i < k; i++) {
    cin >> u >> v;
    g[u].push_back({v, 1});
    g[v].push_back({u, 1});
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> u >> v;
    g[u].push_back({v, 2});
    g[v].push_back({u, 2});
  }
  for (int i = 1; i <= n; i++) {
    fill(visited.begin(), visited.end(), 0);
    temp = 0;
    dfs(i);
    ans = max(ans, temp);
  }
  std::cout << ans << std::endl;
}
