#include <bits/stdc++.h>
using namespace std;
int p[10000];
int parent(int x) { return p[x] == x ? x : parent(p[x]); }
void join(int x, int y) { p[parent(y)] = parent(x); }
vector<int> graph[10000];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int u, v, n, k, m;
  cin >> n >> k;
  for (int i = 0; i < n; i++) p[i] = i;
  for (int i = 0; i < k; i++) {
    cin >> u >> v;
    graph[u - 1].push_back(v - 1);
    graph[v - 1].push_back(u - 1);
    join(u - 1, v - 1);
  }
  set<int> s;
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> u >> v;
    if (parent(u - 1) == parent(v - 1)) s.insert(parent(v - 1));
  }
  int h, ans = INT_MIN, count[10000] = {0};
  for (int i = 0; i < n; i++) {
    h = parent(i);
    if (s.count(h) == 0) {
      count[h]++;
    }
    ans = max(ans, count[h]);
  }
  cout << ans;
  return 0;
}
