#include <bits/stdc++.h>
using namespace std;
long long BigMod(long long B, long long P, long long M) {
  long long R = 1;
  while (P > 0) {
    if (P % 2 == 1) {
      R = (R * B) % M;
    }
    P /= 2;
    B = (B * B) % M;
  }
  return R;
}
int pr[2001];
int find(int r) {
  if (pr[r] == r)
    return r;
  else
    return pr[r] = find(pr[r]);
}
int n, k, m;
int seg[2001];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
  cin >> n;
  for (int i = 1; i <= n; i++) pr[i] = i, seg[i] = 1;
  cin >> k;
  for (int i = 1; i <= k; i++) {
    int a, b;
    cin >> a >> b;
    int u = find(a);
    int v = find(b);
    if (u != v) {
      pr[v] = u;
      seg[u] += seg[v];
    }
  }
  int mx = 0;
  cin >> m;
  for (int i = 1; i <= m; i++) {
    int a, b;
    cin >> a >> b;
    int u = find(a);
    int v = find(b);
    if (u == v) {
      seg[u] = 0;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (find(i) == i) mx = max(mx, seg[i]);
  }
  cout << mx;
}
