#include <bits/stdc++.h>
using namespace std;
const long long M = 1e18;
map<int, int> q;
vector<int> a[2005];
int vis[2005], s;
void dfs(int i) {
  q[i] = 1;
  vis[i] = 1;
  s++;
  for (auto j : a[i]) {
    if (!vis[j]) {
      dfs(j);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, k, m, x, y;
  cin >> n >> k;
  vector<pair<int, int> > b;
  for (int i = 0; i < k; i++) {
    cin >> x >> y;
    a[x].push_back(y);
    a[y].push_back(x);
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    b.push_back({x, y});
  }
  if (k == 0 && m == 0) {
    cout << 1;
    return 0;
  }
  int z = 0, ans = 0;
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      dfs(i);
      if (s == 1) {
        ans = max(ans, s);
        continue;
      }
      for (int j = 0; j < m; j++) {
        if (q[b[j].first] == 1 && q[b[j].second] == 1) {
          z = 1;
          break;
        }
      }
      if (z == 0) ans = max(ans, s);
      s = 0;
      q.clear();
    }
  }
  cout << ans;
  return 0;
}
