#include <bits/stdc++.h>
using namespace std;
const long long int maxn = 2e3 + 5;
vector<long long int> parent(maxn), sz(maxn);
void make_set(long long int v) {
  parent[v] = v;
  sz[v] = 1;
}
long long int find_set(long long int v) {
  if (v == parent[v]) return v;
  return parent[v] = find_set(parent[v]);
}
void union_set(long long int u, long long int v) {
  u = find_set(u);
  v = find_set(v);
  if (u != v) {
    if (sz[u] < sz[v]) swap(u, v);
    parent[v] = u;
    sz[u] += sz[v];
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, k, m, i;
  cin >> n;
  for (i = 0; i < n; i++) make_set(i + 1);
  cin >> k;
  for (i = 0; i < k; i++) {
    long long int u, v;
    cin >> u >> v;
    union_set(u, v);
  }
  cin >> m;
  vector<bool> vis(n + 1, true);
  for (i = 0; i < m; i++) {
    long long int u, v;
    cin >> u >> v;
    u = find_set(u);
    v = find_set(v);
    if (u == v) vis[u] = false;
  }
  long long int mx = 0;
  for (i = 1; i <= n; i++) {
    if (i == parent[i] && vis[i] == true) mx = max(mx, sz[i]);
  }
  cout << mx << "\n";
}
