#include <bits/stdc++.h>
using namespace std;
void solve();
int main() {
  solve();
  return 0;
}
const int maxV = 2000;
const int maxE = 2000 * (2000 - 1) / 2;
int terminal1[maxE + 1];
int terminal2[maxE + 1];
int head[maxV + 1];
int next_el[maxE + 1];
int k = 0;
void add(int u, int v, int t) {
  k++;
  terminal1[k] = v;
  terminal2[k] = t;
  next_el[k] = head[u];
  head[u] = k;
}
int dest[maxV + 1];
set<int> mn[maxV + 1];
int kol_mn = 0;
void DFS(int v) {
  dest[v] = 1;
  mn[kol_mn].insert(v);
  int i = head[v];
  while (i > 0) {
    v = terminal1[i];
    if (terminal2[i] && dest[v] == 0) {
      DFS(v);
    }
    i = next_el[i];
  }
}
int dest1[maxV + 1];
int BFS(int v, int mn_kol) {
  queue<int> och;
  och.push(v);
  dest[v] = 1;
  int i;
  while (!och.empty()) {
    v = och.front();
    och.pop();
    i = head[v];
    while (i > 0) {
      v = terminal1[i];
      if (dest1[v] == 0 && terminal2[i] == 1) {
        och.push(v);
        dest1[v] = 1;
      } else {
        if (terminal2[i] == 0 && mn[mn_kol].find(v) != mn[mn_kol].end()) {
          break;
        }
      }
      i = next_el[i];
    }
    if (i) {
      break;
    }
  }
  if (!och.empty()) {
    return 0;
  } else {
    return 1;
  }
}
void solve() {
  memset(dest, 0, sizeof(dest));
  memset(dest1, 0, sizeof(dest1));
  int n, K, m;
  scanf("%d %d", &n, &K);
  int u, v;
  for (int i = 0; i < K; i++) {
    scanf("%d %d", &u, &v);
    add(u, v, 1);
    add(v, u, 1);
  }
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &u, &v);
    add(u, v, 0);
    add(v, u, 0);
  }
  int max_size = 0;
  for (int i = 1; i <= n; i++) {
    if (dest[i] == 0) {
      DFS(i);
      if (BFS(*mn[kol_mn].begin(), kol_mn)) {
        if (max_size < mn[kol_mn].size()) {
          max_size = mn[kol_mn].size();
        }
      }
      kol_mn++;
    }
  }
  cout << max_size;
}
