#include <bits/stdc++.h>
using namespace std;
vector<int> arr[2001], enemy[2001], ele;
bool vis[2001];
void dfs(int node) {
  vis[node] = true;
  ele.push_back(node);
  for (int child : arr[node]) {
    if (!vis[child]) {
      dfs(child);
    }
  }
}
int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, k, m, a, b;
  cin >> n >> k;
  while (k--) {
    cin >> a >> b;
    arr[a].push_back(b);
    arr[b].push_back(a);
  }
  cin >> m;
  while (m--) {
    cin >> a >> b;
    enemy[a].push_back(b);
    enemy[b].push_back(a);
  }
  int res = 0;
  bool flag;
  for (int i = 1; i < n + 1; i++) {
    if (!vis[i]) {
      ele.clear();
      flag = true;
      dfs(i);
      for (int per : ele) {
        for (int ene : enemy[per]) {
          for (int fri : ele) {
            if (ene == fri) {
              flag = false;
              break;
            }
            if (!flag) {
              break;
            }
          }
          if (!flag) {
            break;
          }
        }
      }
      if (flag) {
        res = max(res, int(ele.size()));
      }
    }
  }
  cout << res;
  return 0;
}
