#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
long long mod = 1000000007;
struct modified_hash {
  static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  long long operator()(uint64_t x) const {
    static const uint64_t random =
        steady_clock::now().time_since_epoch().count();
    return splitmix64(x + random);
  }
};
long long N;
vector<long long> grph[2001];
vector<long long> dis[2001];
set<long long> st;
bool vis[2001];
long long ans = 0;
bool flag = true;
vector<long long> vp;
void dfs(long long i, long long p1) {
  vis[i] = true;
  st.insert(i);
  for (auto x : grph[i]) {
    if (!vis[x]) {
      dfs(x, i);
    }
  }
}
void solve() {
  long long a, b, k, c, n, d, m, x, y, l, r;
  cin >> n >> m;
  memset(vis, false, sizeof(vis));
  for (long long i = 0; i < m; i++) {
    cin >> a >> b;
    grph[a].push_back(b);
    grph[b].push_back(a);
  }
  cin >> k;
  for (long long i = 0; i < k; i++) {
    cin >> a >> b;
    dis[a].push_back(b);
    dis[b].push_back(a);
  }
  long long ans1 = 0;
  for (long long i = 1; i <= n; i++) {
    if (!vis[i]) {
      flag = true;
      ans = 0;
      st.clear();
      dfs(i, -1LL);
      for (auto p : st) {
        for (auto p1 : dis[p]) {
          if (st.find(p1) != st.end()) {
            flag = false;
          }
        }
      }
      if (flag) {
        long long fm = st.size();
        ans1 = max(ans1, fm);
      }
    }
  }
  cout << ans1 << "\n";
  return;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long a, b, c, n, tt, d, m, k, x, y;
  tt = 1;
  while (tt--) {
    solve();
  }
}
