#include <bits/stdc++.h>
using namespace std;
vector<int> fr[100010], en[100010];
int arr[100010], vis[100010], ct[100010], p[100010];
struct UnionFind {
  int par[2000], ra[2000];
  UnionFind() {
    for (int(i) = 0; (i) < (2000); (i)++) par[i] = i, ra[i] = 1;
  }
  int find(int x) { return par[x] == x ? x : par[x] = find(par[x]); }
  bool same(int a, int b) { return find(a) == find(b); }
  void unite(int a, int b) {
    if ((a = find(a)) != (b = find(b))) {
      if (ra[a] < ra[b]) swap(a, b);
      par[b] = a;
      ra[a] += ra[b];
    }
  }
} uf;
int main() {
  int n, k, m, x, y;
  cin >> n;
  cin >> k;
  for (int i = 0; i < k; i++) {
    cin >> x >> y;
    x--, y--;
    uf.unite(x, y);
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    x--, y--;
    x = uf.find(x), y = uf.find(y);
    if (x == y) uf.ra[x] = 0;
  }
  int mx = 0;
  for (int i = 0; i < n; i++) {
    if (uf.find(i) == i) mx = max(mx, uf.ra[i]);
  }
  cout << mx;
  return 0;
}
