#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int N = 2003;
vector<int> g[N];
bool vis[N];
vector<int> q;
void dfs(int u) {
  vis[u] = true;
  q.push_back(u);
  for (auto i : g[u]) {
    if (!vis[i]) dfs(i);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m, a, b;
  cin >> n;
  cin >> m;
  bool arr[n + 1][n + 1];
  memset(arr, false, sizeof(arr));
  for (int j = 0; j < m; ++j) {
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  cin >> m;
  for (int j = 0; j < m; ++j) {
    cin >> a >> b;
    arr[a][b] = arr[b][a] = true;
  }
  int ans = 0;
  int flag;
  for (int i = 1; i <= n; ++i) {
    if (!vis[i]) {
      q.clear();
      flag = 1;
      dfs(i);
      for (int j = 0; j < q.size() && flag; ++j) {
        for (int k = j + 1; k < q.size() && flag; ++k) {
          if (arr[q[j]][q[k]]) flag = 0;
        }
      }
      int ss = q.size();
      if (flag) ans = max(ans, ss);
    }
  }
  cout << ans;
  return 0;
}
