#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (!a) return b;
  return gcd(b % a, a);
}
long long gcdExtended(long long a, long long b, long long *x, long long *y) {
  if (a == 0) {
    *x = 0, *y = 1;
    return b;
  }
  long long x1, y1;
  long long gcd = gcdExtended(b % a, a, &x1, &y1);
  *x = y1 - (b / a) * x1;
  *y = x1;
  return gcd;
}
long long modInv(long long a, long long m) {
  long long x, y;
  long long g = gcdExtended(a, m, &x, &y);
  long long res = (x % m + m) % m;
  return res;
}
long long mpower(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) {
      res = (res * x) % p;
    }
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long power(long long x, long long y) {
  long long res = 1;
  while (y > 0) {
    if (y & 1) res = res * x;
    y = y >> 1;
    x = x * x;
  }
  return res;
}
long long dist(long long x1, long long y1, long long x2, long long y2) {
  return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, x1, y1, x2, y2;
  cin >> n >> x1 >> y1 >> x2 >> y2;
  vector<pair<long long, long long> > v;
  v.push_back(make_pair(0ll, 0ll));
  for (long long i = 0; i < n; i++) {
    long long x, y;
    cin >> x >> y;
    long long tmp1 = dist(x1, y1, x, y);
    long long tmp2 = dist(x2, y2, x, y);
    v.push_back(make_pair(tmp1, tmp2));
  }
  long long ans = LONG_LONG_MAX;
  for (long long i = 0; i < v.size(); i++) {
    long long r1 = v[i].first;
    long long r2 = 0;
    for (long long j = 0; j < v.size(); j++) {
      if (v[j].first > r1) {
        r2 = max(r2, v[j].second);
      }
    }
    ans = min(ans, r1 + r2);
  }
  cout << ans;
}
