#include <bits/stdc++.h>
using namespace std;
vector<int> adj[1000], Color(1000);
int mp[50][50];
int grid[1000][1000];
void BFS(int source);
int mx;
int main() {
  int i, u, v, nodes, edges, source, j;
  scanf("%d %d", &nodes, &edges);
  for (i = 0; i < nodes; i++) {
    adj[i].clear();
  }
  for (i = 0; i < nodes; i++)
    for (j = 0; j < nodes; j++) grid[i][j] = 0;
  for (i = 0; i < edges; i++) {
    scanf("%d %d", &u, &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  int dis;
  scanf("%d", &dis);
  for (i = 1; i <= dis; i++) {
    scanf("%d %d", &u, &v);
    grid[u][v] = 1;
    grid[v][u] = 1;
  }
  for (i = 0; i <= nodes; i++) {
    Color[i] = 0;
  }
  mx = 0;
  for (i = 1; i <= nodes; i++)
    if (Color[i] == 0) BFS(i);
  cout << mx << endl;
  return 0;
}
void BFS(int source) {
  queue<int> Q;
  int i, u, v, cnt = 0, trk = 0, k = 0;
  Color[source] = 1;
  Q.push(source);
  cnt++;
  int V[105];
  V[0] = source;
  k = 1;
  while (!Q.empty()) {
    u = Q.front();
    Q.pop();
    for (i = 0; i < adj[u].size(); i++) {
      v = adj[u][i];
      if (Color[v] == 0) {
        V[k++] = v;
        cnt++;
        Color[v] = 1;
        Q.push(v);
      }
    }
  }
  for (i = 0; i < k; i++)
    for (int j = i + 1; j < k; j++)
      if (grid[V[i]][V[j]] == 1 && grid[V[j]][V[i]] == 1) {
        trk = 1;
        goto ab;
      }
ab:;
  if (trk == 0) mx = max(mx, cnt);
  while (!Q.empty()) Q.pop();
}
