#include <bits/stdc++.h>
using namespace std;
int used[2300];
vector<pair<long long int, long long int> > q, uz1, uz2;
long long int uzaklik(long long int a, long long int b, long long int c,
                      long long int d) {
  return abs(a - c) * abs(a - c) + abs(b - d) * abs(b - d);
}
int main() {
  long long int N, x11, y11, x22, y22, x, y;
  cin >> N >> x11 >> y11 >> x22 >> y22;
  for (long long int i = 1; i <= N; i++) {
    scanf("%lld %lld", &x, &y);
    long long int a = uzaklik(x11, y11, x, y);
    long long int b = uzaklik(x22, y22, x, y);
    uz1.push_back(pair<long long int, long long int>(a, i));
    uz2.push_back(pair<long long int, long long int>(b, i));
  }
  sort(uz1.begin(), uz1.end());
  sort(uz2.begin(), uz2.end());
  long long int minn = -1;
  for (int i = uz1.size() - 1; i >= 0; i--) {
    long long int r1 = 0, r2 = 0;
    r1 = uz1[i].first;
    memset(used, 0, sizeof used);
    for (long long int j = i; j >= 0; j--) {
      used[uz1[j].second] = 1;
    }
    for (long long int j = uz2.size() - 1; j >= 0; j--) {
      if (!used[uz2[j].second]) {
        r2 = uz2[j].first;
        break;
      }
    }
    if (minn == -1 || r1 + r2 < minn) minn = r1 + r2;
  }
  minn = min(minn, uz2[uz2.size() - 1].first);
  cout << minn << endl;
  return 0;
}
