#include <bits/stdc++.h>
using namespace std;
const double ang = 0.123421321;
struct ww {
  double x, y;
  inline double operator*(const ww &A) { return x * A.y - y * A.x; }
  inline ww operator-(const ww &A) {
    ww B = {x - A.x, y - A.y};
    return B;
  }
} a[100010], b[100010], O, Q;
int i, j, k, n, m;
double s1x, s1y, s2x, s2y, A, B, C, X, Y, an;
inline void read(ww &a) {
  double x, y;
  scanf("%lf%lf", &x, &y);
  a.x = cos(ang) * x - sin(ang) * y;
  a.y = sin(ang) * x + cos(ang) * y;
}
inline bool judge(ww a, ww b) {
  return ((a - Q) * (O - Q)) * ((b - Q) * (O - Q)) < 0 &&
         ((Q - a) * (b - a)) * ((O - a) * (b - a)) < 0;
}
inline double Do(double x, double y) {
  return x * x * n - 2 * s1x * x + s2x + y * y * n - 2 * s1y * y + s2y;
}
inline double work(ww a, ww b) {
  if (a.x > b.x) swap(a, b);
  double K = (b.y - a.y) / (b.x - a.x), BB = a.y - a.x * K;
  A = (K * K + 1) * n, B = -s1x * 2 + 2 * K * BB * n - 2 * K * s1y;
  double x = -B / (2 * A);
  if (a.x <= x && x <= b.x)
    return Do(x, K * x + BB);
  else
    return min(Do(a.x, a.y), Do(b.x, b.y));
}
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    read(a[i]);
    s1x += a[i].x, s1y += a[i].y;
    s2x += a[i].x * a[i].x, s2y += a[i].y * a[i].y;
  }
  scanf("%d", &m);
  O.x = 2321321421412.213, O.y = 3424324141.2131;
  A = n, B = -2 * s1x, C = s2x;
  X = -B / A / 2;
  A = n, B = -2 * s1y, C = s2y;
  Y = -B / A / 2;
  Q.x = X, Q.y = Y;
  for (i = 1; i <= m; i++) read(b[i]);
  b[m + 1] = b[1];
  for (i = 1; i <= m; i++) k += judge(b[i], b[i + 1]);
  if (k == 1) {
    printf("%.11lf\n", Do(X, Y));
    return 0;
  }
  an = 1e18;
  for (i = 1; i <= m; i++) an = min(an, work(b[i], b[i + 1]));
  printf("%.11lf\n", an);
  return 0;
}
