#include <bits/stdc++.h>
using namespace std;
const int sz = 1e5 + 5;
vector<int> a[sz];
bool mark[sz];
int items[sz];
int com[sz];
int cc;
int n;
int k;
void dfs(int u) {
  com[u] = cc;
  items[cc]++;
  for (int i = 0; i < (int)a[u].size(); i++) {
    int v = a[u][i];
    if (!com[v]) dfs(v);
  }
}
int main() {
  scanf("%d", &n);
  ;
  scanf("%d", &k);
  ;
  for (int i = 0; i < k; i++) {
    int u;
    int v;
    scanf("%d", &u);
    ;
    scanf("%d", &v);
    ;
    a[u].push_back(v);
    a[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) {
    if (com[i] == 0) {
      cc++;
      dfs(i);
    }
  }
  int m;
  scanf("%d", &m);
  ;
  for (int i = 0; i < m; i++) {
    int u;
    int v;
    scanf("%d", &u);
    ;
    scanf("%d", &v);
    ;
    if (com[u] == com[v]) mark[com[u]] = true;
  }
  int ans = 0;
  for (int i = 1; i <= cc; i++) {
    if (mark[i] == false) ans = max(ans, items[i]);
  }
  printf("%d", ans);
  ;
  puts("");
  ;
}
