#include <bits/stdc++.h>
using namespace std;
int parent[2000 + 342];
int sizze[2000 + 342];
bool possible[2000 + 342];
void init(int n) {
  for (int i = 1; i <= n; i++) {
    parent[i] = i;
    sizze[i] = 1;
    possible[i] = true;
  }
}
int root(int x) {
  while (parent[x] != x) {
    parent[x] = parent[parent[x]];
    x = parent[x];
  }
  return x;
}
void uni(int a, int b) {
  int ra, rb;
  ra = root(a);
  rb = root(b);
  if (ra == rb) return;
  if (sizze[ra] < sizze[rb]) {
    parent[ra] = rb;
    sizze[rb] += sizze[ra];
  } else {
    parent[rb] = ra;
    sizze[ra] += sizze[rb];
  }
}
int main() {
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n;
  init(n);
  cin >> k;
  int x, y;
  while (k--) {
    cin >> x >> y;
    uni(x, y);
  }
  cin >> k;
  while (k--) {
    cin >> x >> y;
    x = root(x);
    y = root(y);
    if (x == y) {
      possible[x] = false;
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (possible[i]) {
      if (parent[i] == i) {
        ans = max(ans, sizze[i]);
      }
    }
  }
  cout << ans;
  return 0;
}
