#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); }
long long power(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = ((res % p) * (x % p)) % p;
    y = y >> 1;
    x = ((x % p) * (x % p)) % p;
  }
  return res;
}
long long raichu(long long x, long long y) {
  long long res = 1;
  while (y > 0) {
    if (y & 1) res = ((res) * (x));
    y = y >> 1;
    x = ((x) * (x));
  }
  return res;
}
bool isprime(long long n) {
  if (n < 2)
    return false;
  else if (n == 2)
    return true;
  else if (n % 2 == 0)
    return false;
  else {
    long long z = sqrt(n);
    for (long long i = 0; i < z - 1; i++)
      if (n % (i + 2) == 0) return false;
    return true;
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1, T;
  T = t;
  while (t--) {
    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++) cin >> v[i].first >> v[i].second;
    vector<pair<long long, long long> > fs(n);
    multiset<long long> s;
    for (long long i = 0; i < n; i++) {
      fs[i].first = (v[i].first - x1) * (v[i].first - x1) +
                    (v[i].second - y1) * (v[i].second - y1);
      fs[i].second = (v[i].first - x2) * (v[i].first - x2) +
                     (v[i].second - y2) * (v[i].second - y2);
      s.insert(fs[i].second);
    }
    sort(fs.begin(), fs.end());
    long long ans = *(s.rbegin());
    for (long long i = 0; i < n; i++) {
      long long z = fs[i].first;
      s.erase(s.find(fs[i].second));
      if (i != n - 1) z += (*s.rbegin());
      ans = min(ans, z);
    }
    cout << ans;
  }
  return 0;
}
