#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const int32_t M = 1e9 + 7;
const int32_t MM = 998244353;
const int32_t N = 1e6 + 1;
long long square(long long x) { return x * x; }
void solve() {
  long long n, x1, y1, x2, y2;
  cin >> n >> x1 >> y1 >> x2 >> y2;
  vector<pair<long long, long long>> v(n);
  for (long long i = 0; i < n; ++i) {
    long long x, y;
    cin >> x >> y;
    v[i] = make_pair(x, y);
  }
  long long ans = INF;
  long long dist = 0;
  for (long long i = 0; i < n; ++i) {
    dist = max(dist, square(v[i].first - x1) + square(v[i].second - y1));
  }
  ans = min(ans, dist);
  dist = 0;
  for (long long i = 0; i < n; ++i) {
    dist = max(dist, square(v[i].first - x2) + square(v[i].second - y2));
  }
  ans = min(ans, dist);
  for (long long i = 0; i < n; ++i) {
    long long dist1 = square(v[i].first - x1) + square(v[i].second - y1);
    dist = dist1;
    long long dist2 = 0;
    for (long long j = 0; j < n; ++j) {
      if (square(v[j].first - x1) + square(v[j].second - y1) <= dist1) continue;
      dist2 = max(dist2, square(v[j].first - x2) + square(v[j].second - y2));
    }
    dist += dist2;
    ans = min(ans, dist);
  }
  for (long long i = 0; i < n; ++i) {
    long long dist1 = square(v[i].first - x2) + square(v[i].second - y2);
    dist = dist1;
    long long dist2 = 0;
    for (long long j = 0; j < n; ++j) {
      if (square(v[j].first - x2) + square(v[j].second - y2) <= dist1) continue;
      dist2 = max(dist2, square(v[j].first - x1) + square(v[j].second - y1));
    }
    dist += dist2;
    ans = min(ans, dist);
  }
  cout << ans << endl;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
