#include <bits/stdc++.h>
using namespace std;
const int ma1 = 3e5 + 5;
string no = "NO", yes = "YES";
const unsigned int MAX1 = 1000000007;
vector<int> G[1000000];
int ma[100001] = {0};
vector<long long> dis;
int sum = 1;
int root1(int a[], int i) {
  while (i != a[i]) {
    i = a[a[i]];
  }
  return i;
}
bool find1(int ar[], int a, int b) {
  if (root1(ar, a) == root1(ar, b))
    return true;
  else
    return false;
}
void union1(int arr[], int sz[], int a, int b) {
  int ar = root1(arr, a);
  int br = root1(arr, b);
  if (ar == br) return;
  if (sz[ar] < sz[br]) {
    arr[ar] = arr[br];
    sz[br] += sz[ar];
  } else {
    arr[br] = arr[ar];
    sz[ar] += sz[br];
  }
}
void initialization(int a[], int sz[], int n) {
  for (int i = 0; i <= n; i++) {
    sz[i] = 1;
    a[i] = i;
  }
}
int main() {
  int n, m;
  cin >> n;
  int ar[n + 1], sz[n + 1];
  initialization(ar, sz, n);
  cin >> m;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    union1(ar, sz, x, y);
  }
  int t;
  cin >> t;
  vector<bool> v(n + 1, true);
  while (t--) {
    int x, y;
    cin >> x >> y;
    if (root1(ar, x) == root1(ar, y)) v[root1(ar, x)] = false;
  }
  int max1 = 0;
  for (int i = 1; i <= n; i++) {
    int x = root1(ar, i);
    if (v[x]) max1 = max(max1, sz[i]);
  }
  cout << max1 << endl;
}
