#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
const double tau = 2 * pi;
const double epsilon = 1e-6;
const int MAX_M = 100100;
int N, M;
long double dN;
long double Sx = 0, SSx = 0;
long double Sy = 0, SSy = 0;
long double poly[MAX_M][2];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cin >> N;
  dN = ((long double)N);
  for (int i = 0; i < N; i++) {
    long double x, y;
    cin >> x >> y;
    Sx += x;
    SSx += x * x;
    Sy += y;
    SSy += y * y;
  }
  long double Cx = Sx / dN, Cy = Sy / dN;
  cin >> M;
  for (int i = 0; i < M; i++) cin >> poly[i][0] >> poly[i][1];
  bool lower = false, upper = false;
  long double mnSS = INFINITY;
  for (int i = 0; i < M; i++) {
    long double x1 = poly[i][0], y1 = poly[i][1];
    long double x2 = poly[(i + 1) % M][0], y2 = poly[(i + 1) % M][1];
    if (abs(x1 - x2) < epsilon) {
      if (Cy > max(y1, y2))
        mnSS = min(SSx + x1 * (dN * x1 - 2.0 * Sx) + SSy +
                       max(y1, y2) * (N * max(y1, y2) - 2.0 * Sy),
                   mnSS);
      else if (Cy < min(y1, y2))
        mnSS = min(SSx + x1 * (dN * x1 - 2.0 * Sx) + SSy +
                       min(y1, y2) * (N * min(y1, y2) - 2.0 * Sy),
                   mnSS);
      else
        min(SSx + x1 * (dN * x1 - 2.0 * Sx) + SSy + Cy * (N * Cy - 2.0 * Sy),
            mnSS);
    } else {
      long double x, y;
      if (x1 < x2) {
        x = x1;
        y = y1;
      } else {
        x = x2;
        y = y2;
      }
      long double m = (y1 - y2) / (x1 - x2);
      if (min(x1, x2) <= Cx && Cx <= max(x1, x2)) {
        long double by = y + (Cx - x) * m;
        if (Cy < by)
          lower = true;
        else
          upper = true;
      }
      long double k = (Sx + m * Sy - dN * x - dN * y * m) / (dN + dN * m * m);
      mnSS =
          min(SSx + x1 * (dN * x1 - 2.0 * Sx) + SSy + y1 * (N * y1 - 2.0 * Sy),
              mnSS);
      mnSS =
          min(SSx + x2 * (dN * x2 - 2.0 * Sx) + SSy + y2 * (N * y2 - 2.0 * Sy),
              mnSS);
      if (k >= 0 && x + k <= max(x1, x2))
        mnSS = min(SSx + (x + k) * (dN * (x + k) - 2.0 * Sx) + SSy +
                       (y + m * k) * (N * (y + m * k) - 2.0 * Sy),
                   mnSS);
    }
  }
  if (lower && upper)
    mnSS = min(SSx + Cx * (dN * Cx - 2.0 * Sx) + SSy + Cy * (N * Cy - 2.0 * Sy),
               mnSS);
  cout << setprecision(9) << fixed << mnSS << '\n';
  return 0;
}
