#include <bits/stdc++.h>
using namespace std;
const int oo = 1000000009;
const double eps = 1e-9;
const int mod = 1000000007;
bool comp(pair<long long, long long> a1, pair<long long, long long> a2) {
  return a1.first > a2.first;
}
int main() {
  long long n, a[4], x, y, min1 = 0, ans = 1e18, min2 = 0, t1, t2;
  cin >> n;
  pair<long long, long long> kaka[2001];
  for (int i = 0; i < 4; ++i) cin >> a[i];
  for (int i = 0; i < n; ++i) {
    cin >> x >> y;
    t1 = (((x - a[0]) * (x - a[0]))) + (((y - a[1]) * (y - a[1])));
    t2 = (((x - a[2]) * (x - a[2]))) + (((y - a[3]) * (y - a[3])));
    kaka[i].first = t1;
    kaka[i].second = t2;
    min1 = ((min1) > (t1) ? (min1) : (t1));
    min2 = ((min2) > (t2) ? (min2) : (t2));
  }
  ans = ((ans) < (min1) ? (ans) : (min1));
  ans = ((ans) < (min2) ? (ans) : (min2));
  sort(kaka, kaka + n, comp);
  min2 = 0;
  for (int i = 0; i < n; ++i) {
    if (i > 0)
      min2 = ((min2) > (kaka[i - 1].second) ? (min2) : (kaka[i - 1].second));
    ans = ((ans) < (kaka[i].first + min2) ? (ans) : (kaka[i].first + min2));
  }
  cout << ans << "\n";
}
