#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e3 + 10;
struct Point {
  long long x, y;
} p[maxn], r1, r2;
long long dis(Point a, Point b) {
  return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
}
bool cmp(Point a, Point b) { return dis(a, r1) < dis(b, r1); }
int main() {
  int n;
  while (~scanf("%d%I64d%I64d%I64d%I64d", &n, &r1.x, &r1.y, &r2.x, &r2.y)) {
    for (int i = 0; i < n; ++i) {
      scanf("%I64d%I64d", &p[i].x, &p[i].y);
    }
    sort(p, p + n, cmp);
    long long ans = 1LL << 62;
    long long x1, x2;
    for (int i = 0; i <= n; ++i) {
      if (!i)
        x1 = 0;
      else
        x1 = dis(r1, p[i - 1]);
      x2 = 0;
      for (int j = i; j < n; ++j) {
        x2 = max(x2, dis(r2, p[j]));
      }
      ans = min(ans, x1 + x2);
    }
    printf("%I64d\n", ans);
  }
  return 0;
}
