#include <bits/stdc++.h>
using namespace std;
string tostr(int n) {
  stringstream rr;
  rr << n;
  return rr.str();
}
long long power(long long a, long long b) {
  return b == 0 ?: a * power(a, b - 1);
}
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); }
vector<int> graph[2020];
bool vis[2020];
int dislike[2020];
int mp[2020];
int bfs(int s, int mx) {
  bool ok = true;
  vis[s] = 1;
  queue<int> q;
  vector<int> vec;
  vec.clear();
  vec.push_back(s);
  q.push(s);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = 0; i < graph[u].size(); i++) {
      int v = graph[u][i];
      if (vis[v] == 0) {
        vec.push_back(v);
        vis[v] = 1;
        q.push(v);
      }
    }
  }
  for (int i = 0; i <= 2010; i++) mp[i] = 0;
  int len = vec.size();
  for (int i = 0; i < vec.size(); i++) mp[dislike[vec[i]]]++;
  for (int i = 2; i <= 2010; i++) {
    if (mp[i] > 1) {
      ok = false;
      break;
    }
  }
  if (ok) mx = max(mx, len);
  return mx;
}
int main() {
  ios::sync_with_stdio(0);
  int n, k;
  while (cin >> n >> k) {
    int c = 2, m, mx = 0;
    for (int i = 0; i <= n; i++) graph[i].clear();
    for (int i = 1; i <= k; i++) {
      int a, b;
      cin >> a >> b;
      graph[a].push_back(b);
      graph[b].push_back(a);
    }
    cin >> m;
    for (int i = 0; i <= 2010; i++) dislike[i] = 0;
    for (int i = 1; i <= m; i++) {
      int a, b;
      cin >> a >> b;
      if (dislike[a] == 0) dislike[a] = c;
      if (dislike[b] == 0) dislike[b] = c;
      c++;
    }
    for (int i = 0; i <= 2010; i++) vis[i] = 0;
    for (int i = 1; i <= n; i++) {
      if (!vis[i]) {
        mx = bfs(i, mx);
      }
    }
    cout << mx << "\n";
  }
  return 0;
}
