#include <bits/stdc++.h>
using namespace std;
signed main() {
  pair<long long, long long> p, q;
  long long n;
  cin >> n >> p.first >> p.second >> q.first >> q.second;
  pair<long long, long long> a[n];
  for (long long i = 0; i < n; ++i) cin >> a[i].first >> a[i].second;
  pair<long long, long long> dist[n];
  for (long long i = 0; i < n; ++i) {
    long long d = (p.first - a[i].first) * (p.first - a[i].first) +
                  (p.second - a[i].second) * (p.second - a[i].second);
    dist[i] = {d, i};
  }
  sort(dist, dist + n);
  long long ans = dist[n - 1].first;
  long long r2 = 0;
  for (long long i = n - 1; i >= 0; --i) {
    long long d = (q.first - a[dist[i].second].first) *
                      (q.first - a[dist[i].second].first) +
                  (q.second - a[dist[i].second].second) *
                      (q.second - a[dist[i].second].second);
    r2 = max(r2, d);
    if (i > 0) {
      ans = min(ans, dist[i - 1].first + r2);
    } else {
      ans = min(ans, r2);
    }
  }
  cout << ans << '\n';
}
