#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int N = 2005;
const int INF = 1e9;
vector<int> v[N], w[N];
bool vis1[N], vis2[N], vis3[N];
vector<int> v2;
int c = 0;
bool f;
void dfs2(int u) {
  vis2[u] = 1;
  for (auto x : w[u]) {
    if ((!vis2[x]) && (vis3[x])) {
      f = 0;
      break;
    }
  }
  return;
}
void dfs1(int u) {
  vis1[u] = 1;
  v2.push_back(u);
  vis3[u] = 1;
  ++c;
  for (auto x : v[u]) {
    if (!vis1[x]) {
      dfs1(x);
    }
  }
  return;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, k, m, a, b;
  cin >> n;
  cin >> k;
  for (int i = 0; i < k; ++i) {
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  cin >> m;
  for (int i = 0; i < m; ++i) {
    cin >> a >> b;
    w[a].push_back(b);
    w[b].push_back(a);
  }
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    if (!vis1[i]) {
      v2.clear();
      memset(vis3, 0, sizeof vis3);
      memset(vis2, 0, sizeof vis2);
      c = 0;
      dfs1(i);
      f = 1;
      for (auto x : v2) {
        if (!vis2[x]) {
          dfs2(x);
          if (!f) break;
        }
      }
      if (f) ans = max(ans, c);
    }
  }
  cout << ans;
}
