#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e8;
const double pi = 3.1415926535897;
const double EPS = (1e-7);
int dcmp(double x, double y) { return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1; }
struct edge {
  int from, to, w;
  edge(int u, int v, int w) : from(u), to(v), w(w) {}
  bool operator<(const edge &e) const { return w > e.w; }
};
vector<int> par;
struct DSU {
  vector<int> grpSz;
  DSU(int n) {
    par.assign(n, 0);
    grpSz.assign(n, 1);
    iota(((par).begin()), ((par).end()), 0);
  }
  int get(int u) { return par[u] == u ? u : get(par[u]); }
  bool unite(int u, int v) {
    int par1 = get(u);
    int par2 = get(v);
    if (par1 == par2) return false;
    if (grpSz[par2] > grpSz[par1]) swap(par1, par2);
    par[par2] = par1;
    grpSz[par1] += grpSz[par2];
    return true;
  }
};
const int N = 5000;
vector<pair<int, int>> bad;
int mark[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  DSU good(n);
  int k;
  cin >> k;
  int x, y;
  for (int i = 0; i < k; i++) {
    cin >> x >> y;
    x--;
    y--;
    good.unite(x, y);
  }
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    x--;
    y--;
    int par1 = good.get(x);
    int par2 = good.get(y);
    if (par1 == par2) mark[par1] = 1;
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (!mark[i] && par[i] == i) ans = max(ans, good.grpSz[i]);
  }
  cout << ans;
}
