#include <bits/stdc++.h>
using namespace std;
vector<int> v[100000];
vector<int> s[190000];
int vis[100000], w = 0;
void dfs(int x) {
  int j;
  vis[x] = 1;
  for (j = 0; j < v[x].size(); j++) {
    if (vis[v[x][j]] == 0) dfs(v[x][j]);
  }
}
int main() {
  int n, i, ans = 0, j, m, k, a, b, o, t, e;
  cin >> n >> k;
  for (i = 0; i < k; i++) {
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  cin >> m;
  for (i = 0; i < m; i++) {
    cin >> a >> b;
    s[a].push_back(b);
    s[b].push_back(a);
  }
  for (i = 1; i <= n; i++) {
    o = 0;
    for (j = 1; j <= n; j++) vis[j] = 0;
    dfs(i);
    w = 0;
    for (j = 1; j <= n; j++) {
      if (vis[j] == 1) {
        o++;
        for (t = 0; t < s[j].size(); t++) {
          if (vis[s[j][t]] == 1) {
            w = 1;
            break;
          }
        }
      }
    }
    if (w == 0) {
      ans = max(ans, o);
    }
  }
  cout << ans;
}
