#include <bits/stdc++.h>
using namespace std;
template <typename Head>
void print(Head&& head) {
  cout << head << '\n';
}
template <typename Head, typename... Tail>
void print(Head&& head, Tail... tail) {
  cout << head << " ";
  print(tail...);
}
void chandan1() {
  int y = 1;
  return;
}
void chandan2() {
  for (int i = 0; i < 10; i++) {
    int x = 1;
  }
  return (chandan1());
}
struct DSU {
  static const int MAXN = 100005;
  int parent[MAXN];
  int size[MAXN];
  bool enemie[200005];
  void init() {
    for (int i = 0; i < MAXN; i++) {
      parent[i] = i;
      size[i] = 1;
      enemie[i] = 0;
    }
  }
  int root(int i) {
    while (parent[i] != i) {
      parent[i] = parent[parent[i]];
      i = parent[i];
    }
    return i;
  }
  void Union(int a, int b) {
    int root_a = root(a);
    int root_b = root(b);
    if (root_a == root_b) return;
    if (size[root_a] < size[root_b]) {
      parent[root_a] = parent[root_b];
      size[root_b] += size[root_a];
    } else {
      parent[root_b] = parent[root_a];
      size[root_a] += size[root_b];
    }
  }
  bool find(int a, int b) { return (a == b or root(a) == root(b)); }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  chandan2();
  while (t--) {
    int n, m, q, k;
    cin >> n >> k;
    DSU uf;
    uf.init();
    for (int i = 0; i < k; i++) {
      int x, y;
      cin >> x >> y;
      uf.Union(x, y);
    }
    cin >> m;
    for (int i = 0; i < m; i++) {
      int x, y;
      cin >> x >> y;
      if (uf.find(x, y)) uf.enemie[uf.root(x)] = 1;
    }
    int maxi = -1;
    for (int i = 1; i <= n; i++)
      if (uf.enemie[uf.root(i)] == 0) maxi = max(maxi, uf.size[uf.root(i)]);
    if (maxi == -1)
      print(0);
    else
      print(maxi);
  }
  return 0;
}
