#include <bits/stdc++.h>
using namespace std;
vector<pair<int, bool>> g[2005];
int a = 0, cnt = 0;
bool vs[2004];
vector<set<int>> h;
void dfs(int u, set<int> &s) {
  vs[u] = 1;
  s.insert(u);
  for (pair<int, bool> v : g[u]) {
    if (v.second == 1) {
      if (!vs[v.first]) {
        dfs(v.first, s);
      }
    }
  }
}
int main() {
  int n;
  cin >> n;
  int m;
  cin >> m;
  int u, v;
  for (int i = 0; i < m; 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, 0});
    g[v].push_back({u, 0});
  }
  for (int i = 1; i <= n; i++) {
    if (!vs[i]) {
      set<int> s;
      dfs(i, s);
      h.push_back(s);
    }
  }
  for (int i = 0; i < h.size(); i++) {
    set<int> r = h[i];
    bool f = 1;
    for (int el : r) {
      for (pair<int, bool> u : g[el]) {
        if (u.second == 0) {
          if (r.find(u.first) != r.end()) f = 0;
        }
      }
    }
    int l = r.size();
    if (f) a = max(a, l);
  }
  cout << a << endl;
  return 0;
}
