#include <bits/stdc++.h>
using namespace std;
int p[2009];
int findset(int x) { return x == p[x] ? x : p[x] = findset(p[x]); }
void unionset(int x, int y) { p[findset(x)] = findset(y); }
bool no[2009], vis[2009];
int cnt[2009];
int main() {
  int m, n;
  cin >> n;
  for (int i = 1; i <= n; i++) p[i] = i;
  cin >> m;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    unionset(x, y);
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    int fx = findset(x);
    int fy = findset(y);
    if (fx == fy) {
      no[fx] = 1;
    }
  }
  for (int i = 1; i <= n; i++) {
    int x;
    x = findset(i);
    cnt[x]++;
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (!no[i]) ans = max(ans, cnt[i]);
  }
  printf("%d", ans);
}
