#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
template <class T>
inline bool chmin(T &a, T b) {
  return a > b ? (a = b, 1) : 0;
}
using Real = double;
using Point = complex<Real>;
ostream &operator<<(ostream &os, Point &p) {
  return os << real(p) << " " << imag(p);
}
istream &operator>>(istream &is, Point &p) {
  Real x, y;
  is >> x >> y;
  p = Point(x, y);
  return is;
}
Real dot(const Point &a, const Point &b) { return real(conj(a) * b); }
Real cross(const Point &a, const Point &b) { return imag(conj(a) * b); }
Point operator*(Point a, Real b) { return Point(real(a) * b, imag(a) * b); }
Point operator/(Point a, Real b) { return Point(real(a) / b, imag(a) / b); }
using Polygon = vector<Point>;
enum { OUT, ON, IN };
int contains(const Polygon &Q, const Point &p) {
  bool in = false;
  for (int i = 0, sz = Q.size(); i < sz; i++) {
    Point a = Q[i] - p, b = Q[(i + 1) % sz] - p;
    if (imag(a) > imag(b)) swap(a, b);
    if (imag(a) <= 0 && 0 < imag(b) && cross(a, b) < 0) in = !in;
    if (cross(a, b) == 0 && dot(a, b) <= 0) return ON;
  }
  return in ? IN : OUT;
}
int main() {
  cout << fixed << setprecision(12);
  int n;
  cin >> n;
  Polygon ps(n);
  for (auto &p : ps) cin >> p;
  int m;
  cin >> m;
  Polygon conv(m);
  for (auto &p : conv) cin >> p;
  Point sum;
  Real c = 0;
  for (auto &p : ps) sum += p, c += norm(p);
  auto calc = [&](Point ans) { return n * norm(ans) - 2 * dot(sum, ans) + c; };
  if (contains(conv, sum / n)) return !(cout << calc(sum / n) << endl);
  Real mi = INF;
  for (int i = 0; i < m; i++) {
    Point a = conv[i], d = conv[(i + 1) % m] - a;
    Real a2 = n * norm(d), a1 = dot(sum - a * n, d);
    Real t = a1 / a2;
    if (0 < t && t < 1)
      chmin(mi, calc(a + d * t));
    else
      chmin(mi, min(calc(a), calc(a + d)));
  }
  cout << mi << endl;
  return 0;
}
