#include <bits/stdc++.h>
using namespace std;
int arr[100001];
int siz[100001];
int root(int i) {
  while (arr[i] != i) {
    arr[i] = arr[arr[i]];
    i = arr[i];
  }
  return i;
}
void we_uni(int a, int b) {
  int ra = root(a);
  int rb = root(b);
  if (siz[ra] < siz[rb]) {
    arr[ra] = rb;
    siz[rb] += siz[ra];
  } else {
    arr[rb] = ra;
    siz[ra] += siz[rb];
  }
}
bool fin(int a, int b) {
  if (root(a) == root(b))
    return 1;
  else
    return 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    arr[i] = i;
    siz[i] = 1;
  }
  set<int> s;
  for (int i = 1; i <= n; i++) s.insert(i);
  while (k--) {
    int x, y;
    cin >> x >> y;
    if (fin(x, y)) continue;
    s.erase(root(x));
    s.erase(root(y));
    we_uni(x, y);
    s.insert(root(x));
  }
  int m;
  cin >> m;
  while (m--) {
    int x, y;
    cin >> x >> y;
    if (fin(x, y)) s.erase(root(x));
  }
  set<int>::iterator itr;
  int maxi = 0;
  for (itr = s.begin(); itr != s.end(); ++itr) maxi = max(maxi, siz[*itr]);
  cout << maxi;
  return 0;
}
