#include <bits/stdc++.h>
using namespace std;
set<int> digits;
std::int32_t main() {
  cout << fixed << setprecision(15);
  std::int64_t n, x1, y1, x2, y2;
  cin >> n >> x1 >> y1 >> x2 >> y2;
  vector<vector<std::int64_t>> dist_sqr(n + 1, vector<std::int64_t>(2));
  for (std::int64_t i = 0; i < n; i++) {
    std::int64_t x, y;
    cin >> x >> y;
    dist_sqr[i][0] = (x - x1) * (x - x1) + (y - y1) * (y - y1);
    dist_sqr[i][1] = (x - x2) * (x - x2) + (y - y2) * (y - y2);
  }
  dist_sqr[n][0] = dist_sqr[n][1] = 0;
  std::int64_t minR = 1e18;
  for (std::int64_t i = 0; i <= n; i++) {
    std::int64_t r1 = dist_sqr[i][0], r2 = 0;
    for (std::int64_t j = 0; j <= n; j++) {
      if (dist_sqr[j][0] > r1 && dist_sqr[j][1] > r2) r2 = dist_sqr[j][1];
    }
    minR = min(minR, r1 + r2);
  }
  cout << minR;
  return 0;
}
