#include <bits/stdc++.h>
using namespace std;
void _fill_int(int* p, int val, int rep) {
  int i;
  for (i = 0; i < rep; i++) p[i] = val;
}
signed long long GETi() {
  signed long long i;
  scanf("%lld", &i);
  return i;
}
int N, M;
signed long long CX1, CY1, C;
int NX[100001], NY[100001];
double X[100001], Y[100001];
bool inside(double x, double y) {
  int lr = 0, i;
  for (i = 0; i < M; i++) {
    double cr =
        (x - X[i]) * (y - Y[(i + 1) % M]) - (y - Y[i]) * (x - X[(i + 1) % M]);
    if (cr < 0) lr |= 1;
    if (cr > 0) lr |= 2;
  }
  return (lr == 1 || lr == 2);
}
void solve() {
  int f, i, j, k, l, x, y;
  cin >> N;
  for (i = 0; i < N; i++) {
    cin >> x >> y;
    CX1 += -2 * x;
    CY1 += -2 * y;
    C += x * (signed long long)x + y * (signed long long)y;
  }
  cin >> M;
  for (i = 0; i < M; i++) cin >> X[i] >> Y[i];
  double mix = CX1 / (-2.0) / N, miy = CY1 / (-2.0) / N;
  if (inside(mix, miy)) {
    double r = N * (mix * mix + miy * miy) + CX1 * mix + CY1 * miy + C;
    (void)printf("%.12lf\n", r);
    return;
  }
  double mi = 1e20;
  for (i = 0; i < M; i++) {
    mi = min(mi, N * (X[i] * X[i] + Y[i] * Y[i]) + CX1 * X[i] + CY1 * Y[i] + C);
    double x1 = X[i], y1 = Y[i], x2 = X[(i + 1) % M], y2 = Y[(i + 1) % M];
    double aa = N * ((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
    double bb = 2 * N * ((x2 - x1) * x1 + (y2 - y1) * y1) + CX1 * (x2 - x1) +
                CY1 * (y2 - y1);
    double t = bb / (-2.0) / aa;
    if (t <= 0 || t >= 1) continue;
    double nx = t * (x2 - x1) + x1;
    double ny = t * (y2 - y1) + y1;
    mi = min(mi, N * (nx * nx + ny * ny) + CX1 * nx + CY1 * ny + C);
  }
  (void)printf("%.12lf\n", mi);
}
int main(int argc, char** argv) {
  string s;
  if (argc == 1) ios::sync_with_stdio(false);
  for (int i = 1; i < argc; i++) s += argv[i], s += '\n';
  for (int i = s.size() - 1; i >= 0; i--) ungetc(s[i], stdin);
  solve();
  return 0;
}
