#include <bits/stdc++.h>
using namespace std;
struct point {
  long long x, y;
  void read() { scanf("%lld%lld", &x, &y); }
} w1, w2, f[2000];
int n;
inline long long dis(const point& i, const point& j) {
  return ((i.x - j.x) * (i.x - j.x) + (i.y - j.y) * (i.y - j.y));
}
long long ans = LLONG_MAX, hh________________, kk__________________;
vector<long long> v1, v2;
int main() {
  scanf("%d", &n);
  w1.read();
  w2.read();
  for (int i = 0; i < n; ++i) f[i].read();
  for (int i = 0; i < n; ++i) {
    v1.push_back(dis(f[i], w1));
    v2.push_back(dis(f[i], w2));
  }
  v1.push_back(0);
  for (int i = 0; i <= n; ++i) {
    hh________________ = v1[i];
    kk__________________ = 0;
    for (int j = 0; j < n; ++j) {
      if (v1[j] > hh________________)
        kk__________________ = max(kk__________________, v2[j]);
    }
    ans = min(ans, hh________________ + kk__________________);
  }
  cout << ans << endl;
}
