#include <bits/stdc++.h>
using namespace std;
vector<long long int> parent, s;
vector<vector<long long int> > adj;
void make_set(long long int v) {
  parent[v] = v;
  s[v] = 1;
}
long long int find_set(long long int v) {
  if (parent[v] == v)
    return v;
  else
    return parent[v] = find_set(parent[v]);
}
void union_sets(long long int a, long long int b) {
  a = find_set(a);
  b = find_set(b);
  if (a != b) {
    parent[b] = a;
    s[a] += s[b];
  }
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long int n, k;
  cin >> n >> k;
  adj.resize(n + 1);
  s.resize(n + 1, 0);
  parent.resize(n + 1);
  for (long long int i = 1; i <= n; i++) make_set(i);
  for (long long int i = 1; i <= k; i++) {
    long long int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
    union_sets(u, v);
  }
  long long int m;
  cin >> m;
  for (long long int i = 1; i <= m; i++) {
    long long int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
    if (find_set(u) == find_set(v)) {
      parent[find_set(u)] = 0;
    }
  }
  long long int ans = 0;
  for (long long int i = 1; i <= n; i++)
    if (parent[i] == i) {
      ans = max(ans, s[i]);
    }
  cout << ans;
  return 0;
}
