#include <bits/stdc++.h>
using namespace std;
const int maxN = 1e3 + 10;
int par[maxN];
int h[maxN];
int find_root(int x) {
  if (x == par[x])
    return x;
  else
    par[x] = find_root(par[x]);
  return par[x];
}
void merge(int x, int y) {
  x = find_root(x);
  y = find_root(y);
  if (h[x] == h[y]) {
    par[y] = x;
    h[x]++;
  }
  if (h[x] > h[y]) par[y] = x;
  if (h[x] < h[y]) par[x] = y;
}
bool hate[maxN][maxN];
vector<int> g[maxN];
int main() {
  ios_base::sync_with_stdio(false);
  for (int i = 0; i < maxN; i++) par[i] = i;
  int n, k, m;
  cin >> n >> k;
  for (int i = 0; i < k; i++) {
    int v, u;
    cin >> v >> u;
    v--, u--;
    if (find_root(v) != find_root(u)) merge(v, u);
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    int v, u;
    cin >> v >> u;
    v--, u--;
    hate[v][u] = hate[u][v] = true;
  }
  for (int i = 0; i < n; i++) g[find_root(i)].push_back(i);
  int mx = 0;
  for (int i = 0; i < n; i++) {
    vector<int> cur = g[i];
    bool ok = 1;
    for (int x = 0; x < cur.size(); x++) {
      for (int y = 0; y < cur.size(); y++) ok &= !(hate[cur[x]][cur[y]]);
    }
    if (ok) mx = max(mx, (int)cur.size());
  }
  cout << mx << '\n';
  return 0;
}
