#include <bits/stdc++.h>
using namespace std;
const int MAX = 2010;
int n;
struct Point {
  int x, y;
  Point() {}
  Point(int _x, int _y) : x(_x), y(_y) {}
};
long long dist2(Point a, Point b) {
  return 1LL * (a.x - b.x) * (a.x - b.x) + 1LL * (a.y - b.y) * (a.y - b.y);
}
Point c1, c2;
Point p[MAX];
void clear() {}
void solve() {
  scanf("%d%d", &c1.x, &c1.y);
  scanf("%d%d", &c2.x, &c2.y);
  for (int i = 0; i < n; i++) scanf("%d%d", &p[i].x, &p[i].y);
  p[n++] = c1;
  p[n++] = c2;
  long long minSum = LLONG_MAX;
  for (int i = 0; i < n; i++) {
    long long r1 = dist2(c1, p[i]);
    long long r2 = 0;
    for (int j = 0; j < n; j++) {
      if (r1 >= dist2(p[j], c1)) continue;
      r2 = max(r2, dist2(p[j], c2));
    }
    minSum = min(minSum, r1 + r2);
  }
  printf("%lld\n", minSum);
}
int main() {
  while (scanf("%d", &n) == 1) {
    clear();
    solve();
    return 0;
  }
  return 0;
}
