#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, long long> > v(3000);
int main() {
  std::ios::sync_with_stdio(false);
  long long n, x1, y1, x2, y2, x, y;
  cin >> n;
  cin >> x1 >> y1 >> x2 >> y2;
  long long d1, d2;
  for (long long i = (long long)(0); i <= (long long)(n - 1); i++) {
    cin >> x >> y;
    v[i].first = abs(x - x1) * abs(x - x1) + abs(y - y1) * abs(y - y1);
    v[i].second = abs(x - x2) * abs(x - x2) + abs(y - y2) * abs(y - y2);
  }
  v.push_back(make_pair(0, 0));
  long long ans = LLONG_MAX;
  for (long long i = (long long)(0); i <= (long long)(n); i++) {
    long long d1 = v[i].first;
    long long d2 = 0;
    for (long long j = (long long)(0); j <= (long long)(n); j++) {
      if (v[j].first > d1) d2 = max(v[j].second, d2);
    }
    ans = min(ans, d1 + d2);
  }
  cout << ans << endl;
  return 0;
}
