#include <bits/stdc++.h>   using namespace std;   const int MAXN = 5000;   int p[MAXN], size[MAXN], n, m;   int find_set(int v) { return v == p[v] ? v : p[v] = find_set(p[v]); }   void union_set(int x, int y) {     x = find_set(x);     y = find_set(y);     if (x != y) {       if (size[x] < size[y]) swap(x, y);       p[x] = y;       size[y] += size[x];     }   }   int main() {     cin >> n >> m;     for (int i = 1; i <= n; i++) size[i] = 1, p[i] = i;     while (m--) {       int x, y;       cin >> x >> y;       union_set(x, y);     }     int mx = 0;     cin >> m;     while (m--) {       int x, y;       cin >> x >> y;       if (find_set(x) == find_set(y)) size[find_set(x)] = 0;     }     for (int i = 1; i <= n; i++) {       mx = max(mx, size[find_set(i)]);     }     cout << mx << endl;   }   