#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, x1, y1, x2, y2;
  cin >> n >> x1 >> y1 >> x2 >> y2;
  vector<pair<long long int, long long int> > a(n);
  for (long long int i = 0; i < n; i++) {
    long long int x, y;
    cin >> x >> y;
    long long int dist1 = (x - x1) * (x - x1) + (y - y1) * (y - y1);
    long long int dist2 = (x - x2) * (x - x2) + (y - y2) * (y - y2);
    a[i] = {dist1, dist2};
  }
  sort(a.begin(), a.end());
  vector<long long int> max_r(n + 1);
  for (long long int i = n - 1; i >= 0; i--)
    max_r[i] = max(max_r[i + 1], a[i].second);
  long long int ans = min(max_r[0], a[n - 1].first);
  for (long long int i = 0; i < n; i++)
    ans = min(ans, a[i].first + max_r[i + 1]);
  cout << ans << "\n";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tc;
  tc = 1;
  while (tc--) {
    solve();
  }
  return 0;
}
