#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 5;
const long long MOD = 998244353;
template <typename P>
struct Cmp {
  bool operator()(const P &p1, const P &p2) {
    if (p1.first < p2.first) return true;
    if (p1.first == p2.first) return p1.second < p2.second;
    return false;
  }
};
long long vis[N];
vector<long long> vp[N];
long long size[N];
long long a[N];
void initialize() {
  for (long long i = 0; i < 2005; i++) {
    a[i] = i;
    size[i] = 1;
  }
}
long long root(long long i) {
  while (a[i] != i) {
    a[i] = a[a[i]];
    i = a[i];
  }
  return i;
}
void merge(long long x, long long y) {
  long long root_A = root(x);
  long long root_B = root(y);
  if (size[root_A] < size[root_B]) {
    a[root_A] = a[root_B];
    size[root_B] += size[root_A];
  } else {
    a[root_B] = a[root_A];
    size[root_A] += size[root_B];
  }
}
bool mark;
void dfs(long long n) {
  vis[n] = 1;
  for (long long i = 0; i < vp[n].size(); i++) {
    if (!vis[vp[n][i]]) {
      dfs(vp[n][i]);
    }
  }
}
int32_t main() {
  long long n;
  long long m;
  cin >> n >> m;
  long long x, y;
  initialize();
  for (long long i = 0; i < m; i++) {
    cin >> x >> y;
    vp[x].push_back(y);
    vp[y].push_back(x);
    if (root(x) != root(y)) {
      merge(x, y);
    }
  }
  long long q;
  cin >> q;
  for (long long i = 0; i < q; i++) {
    cin >> x >> y;
    if (root(x) == root(y)) {
      size[root(x)] = 0;
    }
  }
  long long mx = 0;
  for (long long i = 1; i <= n; i++) {
    mark = true;
    if (!vis[i]) {
      dfs(i);
      if (mark) {
        mx = max(mx, size[root(i)]);
      }
    }
  }
  cout << mx << "\n";
}
