#include <bits/stdc++.h>
using namespace std;
int maxx = 0;
vector<int> vf[3000];
vector<int> ve[3000];
stack<int> st;
int known[3000] = {0};
int curr[3000] = {0};
int fl = 1;
void dfs(int i) {
  known[i] = 1;
  curr[i] = 1;
  st.push(i);
  maxx++;
  int k;
  for (k = 0; k < ve[i].size(); k++) {
    if (curr[ve[i][k]] == 1) {
      fl = 0;
      break;
    }
  }
  for (k = 0; k < vf[i].size(); k++) {
    if (known[vf[i][k]] == 0) {
      dfs(vf[i][k]);
    }
  }
  st.pop();
  return;
}
int main() {
  int n;
  cin >> n;
  int k;
  cin >> k;
  int i;
  int x, y;
  for (i = 0; i < k; i++) {
    cin >> x;
    cin >> y;
    vf[x].push_back(y);
    vf[y].push_back(x);
  }
  int m;
  cin >> m;
  for (i = 0; i < m; i++) {
    cin >> x;
    cin >> y;
    ve[x].push_back(y);
    ve[y].push_back(x);
  }
  int ans = 0;
  for (i = 1; i <= n; i++) {
    if (known[i] == 0) {
      maxx = 0;
      fl = 1;
      memset(curr, 0, sizeof(curr));
      dfs(i);
      if (fl == 1) {
        if (maxx > ans) {
          ans = maxx;
        }
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
