#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int sz = 1e7 + 4;
const signed long long int MIN = numeric_limits<signed long long int>::min();
signed long long int square(signed long long int x) {
  signed long long int v = x * x;
  return v;
}
int main() {
  signed long long int n, x1, y1, x2, y2;
  cin >> n >> x1 >> y1 >> x2 >> y2;
  vector<pair<signed long long int, signed long long int> > v;
  for (int i = 0; i < n; i++) {
    signed long long int x, y;
    cin >> x >> y;
    signed long long int dis1 = square(x - x1) + square(y - y1);
    signed long long int dis2 = square(x - x2) + square(y - y2);
    v.push_back({dis1, dis2});
  }
  sort(v.begin(), v.end());
  signed long long int suff[n + 1];
  memset(suff, 0, sizeof(suff));
  for (int i = n - 1; i >= 0; i--) {
    suff[i] = max(suff[i + 1], v[i].second);
  }
  signed long long int result = min(v[n - 1].first, suff[0]);
  for (int i = 0; i < n; i++) {
    signed long long int r1 = v[i].first;
    signed long long int r2 = suff[i + 1];
    result = min(result, r1 + r2);
  }
  cout << result << "\n";
  return 0;
}
