#include <bits/stdc++.h>
using namespace std;
int n;
long long x[2123];
long long y[2123];
long long x_1;
long long y_1;
long long x_2;
long long y_2;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> x_1 >> y_1 >> x_2 >> y_2;
  priority_queue<pair<long long, pair<long long, long long> > > dist1;
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
    long long rr = (x[i] - x_1) * (x[i] - x_1) + (y[i] - y_1) * (y[i] - y_1);
    pair<long long, long long> p = make_pair(x[i], y[i]);
    dist1.push(make_pair(rr, p));
  }
  priority_queue<long long> dist2;
  long long rec = dist1.top().first;
  long long xx = dist1.top().second.first;
  long long yy = dist1.top().second.second;
  long long rr = (xx - x_2) * (xx - x_2) + (yy - y_2) * (yy - y_2);
  dist2.push(rr);
  dist1.pop();
  while (!dist1.empty()) {
    pair<long long, pair<long long, long long> > pp = dist1.top();
    long long dd = pp.first;
    xx = pp.second.first;
    yy = pp.second.second;
    long long val = dd + dist2.top();
    if (val < rec) {
      rec = val;
    }
    rr = (xx - x_2) * (xx - x_2) + (yy - y_2) * (yy - y_2);
    dist2.push(rr);
    dist1.pop();
  }
  cout << min(rec, dist2.top());
  return 0;
}
