#include <bits/stdc++.h>
using namespace std;
const double INF = 1e99;
const double EPS = 1e-9;
int i, j, k, l, m, n;
double sigx, sigy, sig2x, sig2y, xq, yq, ans, tempx;
struct Point {
  double x, y;
} E[300010], T[300010], gut;
struct Segment {
  Point a, b;
};
double cross(Point A, Point B, Point C) {
  return (B.x - A.x) * (C.y - A.y) - (B.y - A.y) * (C.x - A.x);
}
void Solve(Point A, Point B, Point C, Point D) {
  if (fabs(cross(A, B, C)) <= EPS && fabs(cross(A, B, D)) <= EPS)
    puts("LINE");
  else if ((B.x - A.x) * (D.y - C.y) == (D.x - C.x) * (B.y - A.y))
    puts("NONE");
  else {
    double a1 = A.y - B.y;
    double b1 = B.x - A.x;
    double c1 = A.x * B.y - B.x * A.y;
    double a2 = C.y - D.y;
    double b2 = D.x - C.x;
    double c2 = C.x * D.y - D.x * C.y;
    xq = (b1 * c2 - b2 * c1) / (a1 * b2 - a2 * b1);
    yq = (a2 * c1 - a1 * c2) / (a1 * b2 - a2 * b1);
  }
}
bool IsOnline(Point p, Segment s) {
  if (fabs(cross(s.a, p, s.b)) <= EPS &&
      ((s.a.x) <= (s.b.x) ? (s.a.x) : (s.b.x)) <= p.x &&
      p.x <= ((s.a.x) >= (s.b.x) ? (s.a.x) : (s.b.x)) &&
      ((s.a.y) <= (s.b.y) ? (s.a.y) : (s.b.y)) <= p.y &&
      p.y <= ((s.a.y) >= (s.b.y) ? (s.a.y) : (s.b.y)))
    return true;
  return false;
}
bool Segment_crossing(Segment u, Segment v) {
  return ((((u.a.x) >= (u.b.x) ? (u.a.x) : (u.b.x)) >=
           ((v.a.x) <= (v.b.x) ? (v.a.x) : (v.b.x))) &&
          (((v.a.x) >= (v.b.x) ? (v.a.x) : (v.b.x)) >=
           ((u.a.x) <= (u.b.x) ? (u.a.x) : (u.b.x))) &&
          (((u.a.y) >= (u.b.y) ? (u.a.y) : (u.b.y)) >=
           ((v.a.y) <= (v.b.y) ? (v.a.y) : (v.b.y))) &&
          (((v.a.y) >= (v.b.y) ? (v.a.y) : (v.b.y)) >=
           ((u.a.y) <= (u.b.y) ? (u.a.y) : (u.b.y))) &&
          (cross(v.a, u.b, u.a) * cross(u.b, v.b, u.a) >= 0) &&
          (cross(u.a, v.b, v.a) * cross(v.b, u.b, v.a) >= 0));
}
bool Inside(Point t) {
  Segment seg;
  Segment pp;
  int num = 0;
  Point MM;
  MM.y = t.y;
  MM.x = INF;
  pp.a = t;
  pp.b = MM;
  for (int i = 0; i < m; i++) {
    seg.a = T[i];
    seg.b = T[(i + 1) % m];
    if (IsOnline(t, seg)) return true;
    if (fabs(seg.a.y - seg.b.y) < EPS) continue;
    if (IsOnline(seg.a, pp)) {
      if (seg.a.y > seg.b.y) num++;
    } else if (IsOnline(seg.b, pp)) {
      if (seg.b.y > seg.a.y) num++;
    } else if (Segment_crossing(pp, seg))
      num++;
  }
  if (num % 2 == 1) return true;
  return false;
}
double getans(Point guter) {
  return n * (guter.x * guter.x + guter.y * guter.y) - 2 * sigx * guter.x -
         2 * sigy * guter.y;
}
double adv(Point e1, Point e2) {
  double cans = ((getans(e1)) <= (getans(e2)) ? (getans(e1)) : (getans(e2)));
  if (e1.x == e2.x) {
    Point swa;
    swa = e1;
    e1 = e2;
    e2 = swa;
    double swa1;
    swa1 = sigx;
    sigx = sigy;
    sigy = swa1;
    swa1 = sig2x;
    sig2x = sig2y;
    sig2y = swa1;
  }
  if (e1.x != e2.x) {
    double k1 = (e1.y - e2.y) / (e1.x - e2.x);
    double b1 = e1.y - k1 * e1.x;
    if (abs(k1 + 1) > 1e-4)
      tempx = (sigy * k1 + sigx - n * b1 * k1) / n / (k1 * k1 + 1);
    if ((e1.x - tempx) * (e2.x - tempx) <= EPS) {
      double tempy = k1 * tempx + b1;
      Point temp3;
      temp3.x = tempx;
      temp3.y = tempy;
      cans = ((cans) <= (getans(temp3)) ? (cans) : (getans(temp3)));
    }
  }
  if (e1.y == e2.y) {
    double swa1;
    swa1 = sigx;
    sigx = sigy;
    sigy = swa1;
    swa1 = sig2x;
    sig2x = sig2y;
    sig2y = swa1;
  }
  return cans;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  sigx = 0;
  sigy = 0;
  sig2x = 0;
  sig2y = 0;
  for (i = 1; i <= n; i++) {
    cin >> E[i].x >> E[i].y;
    sigx += E[i].x;
    sigy += E[i].y;
    sig2x += E[i].x * E[i].x;
    sig2y += E[i].y * E[i].y;
  }
  cin >> m;
  for (i = 0; i < m; i++) {
    cin >> T[i].x >> T[i].y;
  }
  gut.x = sigx / n;
  gut.y = sigy / n;
  if (Inside(gut)) {
    double ans = n * (gut.x * gut.x + gut.y * gut.y) - 2 * sigx * gut.x -
                 2 * sigy * gut.y;
    printf("%.10f\n", ans + sig2x + sig2y);
  } else {
    ans = INF;
    for (i = 0; i < m; i++) {
      ans = ((adv(T[i], T[(i + 1) % m])) <= (ans) ? (adv(T[i], T[(i + 1) % m]))
                                                  : (ans));
    }
    printf("%.10f\n", ans + sig2x + sig2y);
  }
}
