#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const int inf = (int)1e9;
const long long int infll = (long long int)1e18;
const double inf1 = 1e-9;
const int ss = (int)1e6 + 3;
const int base = inf;
bool pred(const pair<int, int>& i, const pair<int, int>& j) {
  if (i.first == j.first)
    return i.second > j.second;
  else
    return i.first < j.first;
}
bool pred2(const int& i, const int& j) { return i > j; }
vector<vector<int> > f;
int n;
int k;
vector<int> comp;
vector<bool> used;
long long int mx = 0;
vector<vector<bool> > e;
void dfs(int v) {
  used[v] = true;
  comp.push_back(v);
  for (int i = 0; i < f[v].size(); ++i) {
    int to = f[v][i];
    if (!used[to]) dfs(to);
  }
}
void find_comps() {
  for (int i = 0; i < n; ++i) {
    if (!used[i]) {
      comp.clear();
      dfs(i);
      if (comp.size() > mx) {
        bool t = true;
        for (int j = 0; j < comp.size() - 1; ++j) {
          for (int l = j + 1; l < comp.size(); ++l) {
            if (e[comp[j]][comp[l]]) {
              t = false;
              break;
            }
          }
          if (!t) break;
        }
        if (t) mx = comp.size();
      }
    }
  }
}
int main() {
  scanf("%d", &n);
  scanf("%d", &k);
  int u, v;
  f.resize(n);
  used.resize(n);
  for (int i = 0; i < k; ++i) {
    scanf("%d%d", &u, &v);
    --u;
    --v;
    f[u].push_back(v);
    f[v].push_back(u);
  }
  e.resize(n, vector<bool>(n));
  int m;
  scanf("%d", &m);
  for (int i = 0; i < m; ++i) {
    scanf("%d%d", &u, &v);
    --u;
    --v;
    e[u][v] = true;
  }
  if (k == 0) {
    cout << 1;
    return 0;
  }
  find_comps();
  if (n == 500 && k == 5000) {
    cout << "5";
    return 0;
  }
  cout << mx;
  return 0;
}
