#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long ans, b[2001], s;
vector<int> f[2001], e[2001];
void dfs(int x) {
  b[x] = 1;
  s++;
  for (long long i = 0; i < f[x].size(); i++)
    if (!b[f[x][i]]) dfs(f[x][i]);
  for (int j = 0; j < e[x].size() && s >= 0; j++)
    if (b[e[x][j]]) s = -1e9;
}
int main() {
  long long n, m, x, y, k;
  cin >> n >> k;
  for (long long i = 0; i < k; i++) {
    cin >> x >> y;
    f[x].push_back(y);
    f[y].push_back(x);
  }
  cin >> m;
  for (long long i = 0; i < m; i++) {
    cin >> x >> y;
    e[x].push_back(y);
    e[y].push_back(x);
  }
  for (long long i = 1; i <= n; i++) {
    s = 0;
    dfs(i);
    ans = max(s, ans);
    memset(b, 0, sizeof(b));
  }
  cout << ans;
  return 0;
}
