#include <bits/stdc++.h>
void solve() {
  int n;
  std::cin >> n;
  std::vector<int64_t> x(n + 2), y(n + 2);
  for (int i = 0; i < n + 2; ++i) {
    std::cin >> x[i] >> y[i];
  }
  std::vector<std::pair<int64_t, std::pair<int64_t, int64_t>>> v;
  for (int i = 2; i < n + 2; ++i) {
    v.push_back({(x[i] - x[0]) * (x[i] - x[0]) + (y[i] - y[0]) * (y[i] - y[0]),
                 {x[i], y[i]}});
  }
  std::sort(v.begin(), v.end());
  int64_t a = 0;
  for (int i = 2; i < n + 2; ++i) {
    a = std::max(a,
                 (x[i] - x[1]) * (x[i] - x[1]) + (y[i] - y[1]) * (y[i] - y[1]));
  }
  for (int i = 0; i < (int)v.size(); ++i) {
    int64_t b = 0;
    for (int j = i + 1; j < (int)v.size(); ++j) {
      b = std::max(
          b, (v[j].second.first - x[1]) * (v[j].second.first - x[1]) +
                 (v[j].second.second - y[1]) * (v[j].second.second - y[1]));
    }
    a = std::min(a, v[i].first + b);
  }
  std::cout << a;
}
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  solve();
  return 0;
}
