#include <bits/stdc++.h>
using namespace std;
class Person {
  vector<int> fr, notfr;

 public:
  void add(int s, int n) {
    if (s)
      fr.push_back(n);
    else
      notfr.push_back(n);
  }
  vector<int> getvt(int s) {
    if (s) return fr;
    return notfr;
  }
};
Person p[2003];
unordered_set<int> vis;
int dfs(unordered_set<int> &dsl, vector<int> fr, int n, int &ok) {
  int count = 0;
  if (vis.find(n) == vis.end()) {
    vis.insert(n);
    vector<int> temp = p[n].getvt(0);
    for (int i : temp) dsl.insert(i);
  }
  for (int i : fr) {
    if (vis.find(i) == vis.end()) count += dfs(dsl, p[i].getvt(1), i, ok);
    if (dsl.find(i) != dsl.end()) ok = 0;
  }
  return (ok ? count + 1 : 0);
}
void solve() {
  int n, k, x, y;
  cin >> n >> k;
  for (int i = 1; i <= k; i++) {
    cin >> x >> y;
    p[x].add(1, y);
    p[y].add(1, x);
  }
  int m;
  cin >> m;
  for (int i = 1; i <= m; i++) {
    cin >> x >> y;
    p[x].add(0, y);
    p[y].add(0, x);
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (vis.find(i) == vis.end()) {
      unordered_set<int> dsl;
      int ok = 1;
      ans = max(ans, dfs(dsl, p[i].getvt(1), i, ok));
    }
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
