#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, x1, y1, x2, y2, x, y;
  cin >> n >> x1 >> y1 >> x2 >> y2;
  vector<pair<long long int, long long int> > dist(n);
  for (long long int i = 0; i < n; i++) {
    cin >> x >> y;
    dist[i].first = (x - x1) * (x - x1) + (y - y1) * (y - y1);
    dist[i].second = (x - x2) * (x - x2) + (y - y2) * (y - y2);
  }
  sort(dist.begin(), dist.end());
  for (long long int i = n - 2; i >= 0; i--) {
    dist[i].second = max(dist[i].second, dist[i + 1].second);
  }
  long long int mini = dist[0].second;
  for (long long int i = 0; i < n - 1; i++) {
    mini = min(mini, dist[i].first + dist[i + 1].second);
  }
  mini = min(mini, dist[n - 1].first);
  cout << mini << endl;
  return 0;
}
