#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<pair<double, double> > t;
vector<pair<double, double> > s;
pair<double, double> sgma;
pair<double, double> sq_sgma;
pair<double, double> avg_p;
void init() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    pair<double, double> temp;
    cin >> temp.first >> temp.second;
    t.push_back(temp);
    sgma.first += temp.first, sgma.second += temp.second;
    sq_sgma.first += (temp.first * temp.first),
        sq_sgma.second += (temp.second * temp.second);
  }
  avg_p.first = (double)sgma.first / n;
  avg_p.second = (double)sgma.second / n;
  cin >> m;
  for (int i = 0; i < m; i++) {
    pair<double, double> temp;
    cin >> temp.first >> temp.second;
    s.push_back(temp);
  }
}
double cross(pair<double, double> a, pair<double, double> b,
             pair<double, double> c) {
  return (b.first - a.first) * (c.second - b.second) -
         (b.second - a.second) * (c.first - b.first);
}
double dot(pair<double, double> p, pair<double, double> p1,
           pair<double, double> p2) {
  return (p2.first - p1.first) * (p.first - p1.first) +
         (p2.second - p1.second) * (p.second - p1.second);
}
bool check_inside(pair<double, double> p) {
  for (int i = 0; i < m; i++) {
    if (cross(s[i], p, s[(i + 1) % m]) < 0) return false;
  }
  return true;
}
double dist(pair<double, double> p) {
  return (n * p.first * p.first + sq_sgma.first - 2 * p.first * sgma.first) +
         (n * p.second * p.second + sq_sgma.second -
          2 * p.second * sgma.second);
}
void process() {
  if (check_inside(avg_p)) {
    cout << dist(avg_p) << endl;
    return;
  }
  double ans = dist(s[0]);
  for (int i = 0; i < m; i++) {
    ans = min(ans, dist(s[i]));
    pair<double, double> p1 = s[i];
    pair<double, double> p2 = s[(i + 1) % m];
    double numerator = dot(avg_p, p1, p2);
    double denominator =
        pow(p1.first - p2.first, 2) + pow(p1.second - p2.second, 2);
    double rtio = numerator / denominator;
    if (rtio > 0 && rtio < 1) {
      pair<double, double> temp_new;
      temp_new.first = p1.first * (1 - rtio) + p2.first * (rtio);
      temp_new.second = p1.second * (1 - rtio) + p2.second * (rtio);
      ans = min(ans, dist(temp_new));
    }
  }
  cout << ans << endl;
  return;
}
int main() {
  init();
  process();
  return 0;
}
