#include <bits/stdc++.h>
using namespace std;
const int MAXX = 2500;
vector<int> G[MAXX];
set<int> D[MAXX];
int color[MAXX];
void DFS(int v, list<int> &A) {
  if (color[v]) return;
  color[v] = 1;
  A.push_back(v);
  for (__typeof((G[v]).begin()) a = (G[v]).begin(); a != (G[v]).end(); a++)
    DFS(*a, A);
}
int goDFS(int i) {
  list<int> Q;
  DFS(i, Q);
  for (__typeof((Q).begin()) a = (Q).begin(); a != (Q).end(); a++)
    for (__typeof((Q).begin()) b = (Q).begin(); b != (Q).end(); b++)
      if (D[*a].find(*b) != D[*a].end()) return 0;
  return Q.size();
}
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  for (int i = 0; i < k; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    G[a].push_back(b);
    G[b].push_back(a);
  }
  int w;
  scanf("%d", &w);
  for (int i = 0; i < w; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    D[a].insert(b);
    D[b].insert(a);
  }
  int maxx = 0;
  for (int i = 1; i <= n; i++) {
    if (color[i] == 0) maxx = max(goDFS(i), maxx);
  }
  printf("%d\n", maxx);
  return 0;
}
