#include <bits/stdc++.h>
using namespace std;
int main() {
  long int n;
  long long int a[2];
  long long int b[2];
  cin >> n;
  cin >> a[0] >> a[1] >> b[0] >> b[1];
  long long int r1 = 0, r2 = 0;
  long long int x, y;
  vector<pair<long long int, long long int> > d;
  d.push_back(make_pair(0, 0));
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    long long int d1 = ((a[0] - x) * (a[0] - x) + (a[1] - y) * (a[1] - y));
    long long int d2 = ((b[0] - x) * (b[0] - x) + (b[1] - y) * (b[1] - y));
    d.push_back(make_pair(d1, d2));
  }
  long long int r = 9223372036854775807;
  r2 = 0;
  for (int i = 0; i < n + 1; i++) {
    r1 = d[i].first;
    r2 = 0;
    for (long int j = 0; j < n + 1; j++) {
      if (d[j].first > r1) {
        if (d[j].second > r2) {
          r2 = d[j].second;
        }
      }
    }
    r = min(r, r1 + r2);
  }
  cout << r << endl;
}
