#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 5, inf = 1e18, mod = 1e9 + 7;
const long double pi = 3.141592653589793238;
bool check_prime(long long n) {
  long long flag = 0, i;
  for (i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      flag = 1;
      break;
    }
  }
  if (n == 1) {
    return false;
  } else if (flag == 0 || n == 2 || n == 3) {
    return true;
  } else {
    return false;
  }
}
long long fastexpo(long long a, long long b, long long MOD) {
  long long result = 1;
  while (b > 0) {
    if (b % 2 == 1) {
      result = (result * a) % MOD;
    }
    a = (a * a) % MOD;
    b = b / 2;
  }
  return result;
}
vector<long long> G[N];
long long vis[N];
vector<long long> vec[2005];
void dfs(long long node, long long count) {
  long long i;
  vis[node] = 1;
  vec[count].push_back(node);
  for (i = 0; i < G[node].size(); i++) {
    if (vis[G[node][i]] == 0) {
      dfs(G[node][i], count);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, u, v, i, k, m, ma, c, j, count;
  cin >> n;
  cin >> m;
  for (i = 1; i <= m; i++) {
    cin >> u >> v;
    G[u].push_back(v);
    if (u != v) {
      G[v].push_back(u);
    }
  }
  vector<pair<long long, long long> > vi;
  cin >> k;
  for (i = 1; i <= k; i++) {
    cin >> u >> v;
    vi.push_back({u, v});
  }
  count = 0;
  for (i = 1; i <= n; i++) {
    if (vis[i] == 0) {
      dfs(i, count);
      count++;
    }
  }
  ma = 0;
  for (i = 0; i < count; i++) {
    sort(vec[i].begin(), vec[i].end());
    c = 1;
    for (j = 0; j < k; j++) {
      if (binary_search(vec[i].begin(), vec[i].end(), vi[j].first) &&
          binary_search(vec[i].begin(), vec[i].end(), vi[j].second)) {
        c = 0;
        break;
      }
    }
    if (c == 1) {
      c = vec[i].size();
      ma = max(ma, c);
    }
  }
  cout << ma << "\n";
  return 0;
}
