#include <bits/stdc++.h>
using namespace std;
class unionfind {
 public:
  vector<int> a, size;

 public:
  int comp;

 public:
  void setsize(int n) {
    comp = n;
    for (int i = 0; i < n; i++) {
      a.push_back(i);
      size.push_back(1);
    }
  }

 public:
  void refresh() {
    a.clear();
    size.clear();
    comp = 0;
  }

 public:
  int root(int i) { return (a[i] == i) ? i : (a[i] = root(a[i])); }

 public:
  bool find(int n1, int n2) { return (root(n1) == root(n2)); }

 public:
  void uni(int n1, int n2) {
    int r1 = root(n1);
    int r2 = root(n2);
    if (r1 == r2) return;
    if (size[r1] < size[r2]) {
      a[r1] = r2;
      size[r2] += size[r1];
    } else {
      a[r2] = r1;
      size[r1] += size[r2];
    }
    comp--;
  }
};
int dx[] = {-1, 1, 0, 0, 0, 0, 0, 0};
int dy[] = {0, 0, 1, -1, 0, 0, 0, 0};
const int inf = 1000000000;
const int seivesize = 10005;
const double eps = 0.000000009;
int main() {
  int n;
  cin >> n;
  int m1, m2;
  cin >> m1;
  unionfind ob;
  ob.setsize(n);
  for (int i = 0; i < m1; i++) {
    int t1, t2;
    cin >> t1 >> t2;
    t1--;
    t2--;
    ob.uni(t1, t2);
  }
  cin >> m2;
  for (int i = 0; i < m2; i++) {
    int t1, t2;
    cin >> t1 >> t2;
    t1--;
    t2--;
    if (ob.find(t1, t2)) {
      ob.size[ob.root(t1)] = -1;
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans = max(ans, ob.size[ob.root(i)]);
  }
  cout << ans << endl;
  return 0;
}
