#include <bits/stdc++.h>
using namespace std;
int P[111111];
int sz[111111];
int find(int x) { return (P[x] == x ? x : P[x] = find(P[x])); }
void Union(int x, int y, int type) {
  x = find(x), y = find(y);
  if (sz[x] < sz[y]) swap(x, y);
  if (x == y) {
    if (type == -1) P[x] = 0;
    return;
  }
  if (type == -1) return;
  sz[x] += sz[y];
  P[y] = x;
}
int main() {
  int N, K;
  cin >> N >> K;
  for (int i = 1; i <= N; i++) P[i] = i, sz[i] = 1;
  while (K--) {
    int u, v;
    cin >> u >> v;
    Union(u, v, 1);
  }
  cin >> K;
  while (K--) {
    int u, v;
    cin >> u >> v;
    Union(u, v, -1);
  }
  int best = 0;
  for (int i = 1; i <= N; i++)
    if (find(i)) best = max(best, sz[find(i)]);
  cout << best << endl;
}
