#include <bits/stdc++.h>
using namespace std;
int n = 0;
int **relation;
bool *invited;
int *result_set;
int cur_num = 0;
bool canInvite(int x) {
  for (int i = 0; i < cur_num; i++) {
    if (relation[x][result_set[i]] == -1) {
      return false;
    }
  }
  return true;
}
void fill(bool *filled, int x, bool value) {
  invited[x] = value;
  filled[x] = true;
  for (int i = 0; i < n; i++) {
    if (relation[x][i] == 1 && filled[i] == false) {
      fill(filled, i, value);
    }
  }
}
void fillHisFriends(int x, bool value) {
  bool *filled;
  filled = new bool[n];
  for (int i = 0; i < n; i++) {
    filled[i] = false;
  }
  fill(filled, x, value);
}
bool invite(int x) {
  if (invited[x] == true) {
    return true;
  }
  if (canInvite(x) == true) {
    result_set[cur_num++] = x;
    invited[x] = true;
  } else {
    fillHisFriends(x, true);
    cur_num = 0;
    return false;
  }
  for (int i = 0; i < n; i++) {
    if (relation[x][i] == 1) {
      if (invite(i) == false) {
        return false;
      }
    }
  }
  return true;
}
int main() {
  cin >> n;
  invited = new bool[n];
  result_set = new int[n];
  relation = new int *[n];
  for (int i = 0; i < n; i++) {
    relation[i] = new int[n];
    invited[i] = false;
    for (int j = 0; j < n; j++) {
      relation[i][j] = 0;
    }
  }
  int likes = 0;
  cin >> likes;
  for (int i = 0; i < likes; i++) {
    int m = 0, n = 0;
    cin >> m >> n;
    relation[m - 1][n - 1] = 1;
    relation[n - 1][m - 1] = 1;
  }
  int dislikes = 0;
  cin >> dislikes;
  for (int i = 0; i < dislikes; i++) {
    int m = 0, n = 0;
    cin >> m >> n;
    relation[m - 1][n - 1] = -1;
    relation[n - 1][m - 1] = -1;
  }
  int result = 0;
  for (int i = 0; i < n; i++) {
    if (invited[i] == false) {
      cur_num = 0;
      if (invite(i) == true) {
        if (cur_num > result) {
          result = cur_num;
        }
      }
    }
  }
  cout << result;
  return 0;
}
