#include <bits/stdc++.h>
using namespace std;
long long int pw(long long int p, long long int q) {
  long long int x = 1, y = p;
  while (q > 0) {
    if (q & 1) {
      x = (x * y);
    }
    y = (y * y);
    q >>= 1;
  }
  return x;
}
int main() {
  int n, i, j;
  long long int x1[3], y1[3], x[2005], y[2005], r1 = 0, r2 = 0, res = LLONG_MAX;
  scanf("%d", &n);
  scanf("%lld %lld %lld %lld", &x1[0], &x1[1], &y1[0], &y1[1]);
  vector<pair<long long int, long long int> > v;
  for (i = 0; i < n; ++i) {
    scanf("%lld %lld", &x[i], &y[i]);
    v.push_back(make_pair(pw(x[i] - x1[0], 2) + pw(y[i] - x1[1], 2),
                          pw(x[i] - y1[0], 2) + pw(y[i] - y1[1], 2)));
  }
  v.push_back(make_pair(0, 0));
  for (i = 0; i <= n; ++i) {
    r1 = v[i].first;
    r2 = 0;
    for (j = 0; j <= n; ++j) {
      if (v[j].first > r1) r2 = max(r2, v[j].second);
    }
    res = min(res, r1 + r2);
  }
  printf("%lld", res);
  return 0;
}
