#include <bits/stdc++.h>
using namespace std;
vector<int> G[2001];
vector<int> T[2001];
bool vist[2001];
bool no[2001];
bool here[2001];
int as;
bool dfs(int u) {
  as++;
  vist[u] = 1;
  here[u] = 1;
  bool f = true;
  for (typeof T[u].begin() i = T[u].begin(); i != T[u].end(); i++) {
    if (here[*i]) f = false;
    no[*i] = 1;
  }
  for (typeof G[u].begin() i = G[u].begin(); i != G[u].end(); i++) {
    if (no[*i]) f = false;
    if (!vist[*i])
      if (!dfs(*i)) f = false;
  }
  return f;
}
int main(int argc, char const *argv[]) {
  int n, k, m, a, b;
  cin >> n >> k;
  for (int i = 0; i < k; ++i) {
    cin >> a >> b;
    a--, b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  cin >> m;
  for (int i = 0; i < m; ++i) {
    cin >> a >> b;
    a--, b--;
    T[a].push_back(b);
    T[b].push_back(a);
  }
  int ans = 0;
  memset(vist, 0, sizeof vist);
  for (int i = 0; i < n; ++i) {
    memset(no, 0, sizeof no);
    memset(here, 0, sizeof here);
    if (!vist[i]) {
      as = 0;
      if (dfs(i)) ans = max(as, ans);
    }
  }
  cout << ans << endl;
  return 0;
}
