#include <bits/stdc++.h>
using namespace std;
vector<int> par(20001, -1), ran(20001, 1), can_parent(20001, 1);
vector<int> arr[20001];
int vis[20001];
int siz;
bool flag;
int find(int node) {
  if (par[node] == -1) return node;
  return par[node] = find(par[node]);
}
void unite(int a, int b) {
  int s1 = find(a);
  int s2 = find(b);
  if (s1 != s2) {
    if (ran[s1] >= ran[s2]) {
      par[s2] = s1;
      ran[s1] += ran[s2];
    } else {
      par[s1] = s2;
      ran[s2] += ran[s1];
    }
  }
  return;
}
bool dfs(int node) {
  vis[node] = 1;
  if (can_parent[node] == 0)
    flag = false;
  else
    siz++;
  for (int child : arr[node])
    if (vis[child] == 0) dfs(child);
  return flag;
}
int main() {
  int v, k, m, a, b;
  cin >> v;
  cin >> k;
  for (int i = 0; i < k; i++) {
    cin >> a >> b;
    arr[a].push_back(b);
    arr[b].push_back(a);
    unite(a, b);
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    int s1 = find(a);
    int s2 = find(b);
    if (s1 == s2) {
      can_parent[s1] = 0;
    }
  }
  int ans = 0;
  for (int i = 1; i <= v; i++) {
    if (vis[i] == 0) {
      siz = 0, flag = true;
      if (dfs(i)) {
        ans = max(ans, siz);
      }
    }
  }
  cout << ans;
  return 0;
}
