#include <bits/stdc++.h>
using namespace std;
const char IN[] = "_.in";
const char OUT[] = "_.out";
const int maxn = 2100;
int ntest = 0, test;
int n, k, m, u, v, res, dem;
vector<int> a[maxn];
bool dis[maxn][maxn];
bool tham[maxn];
int b[maxn];
void nhap() {
  cin >> n;
  cin >> k;
  for (int i = (1); i <= (k); i++) {
    cin >> u >> v;
    a[u].push_back(v);
    a[v].push_back(u);
  }
  cin >> m;
  for (int i = (1); i <= (m); i++) {
    cin >> u >> v;
    dis[u][v] = true;
  }
}
void dfs(int u) {
  tham[u] = true;
  dem++;
  b[dem] = u;
  for (__typeof(a[u].begin()) i = a[u].begin(); i != a[u].end(); i++) {
    int v = *i;
    if (!tham[v]) dfs(v);
  }
}
void solve() {
  res = 0;
  memset((tham), (false), sizeof(tham));
  for (int i = (1); i <= (n); i++)
    if (!tham[i]) {
      dem = 0;
      dfs(i);
      bool ok = true;
      for (int j = (1); j <= (dem); j++)
        for (int o = (1); o <= (dem); o++)
          if (dis[b[j]][b[o]]) {
            ok = false;
            break;
          }
      if (ok) res = max(res, dem);
    }
  cout << res;
}
int main() {
  nhap();
  solve();
  return 0;
}
