#include <bits/stdc++.h>
using namespace std;
long long minn(long long &a, long long b) {
  if (b < a) {
    a = b;
  }
}
int main() {
  long long n, x1, y1, x2, y2;
  cin >> n >> x1 >> y1 >> x2 >> y2;
  long long r1(0), r2(0), x, y;
  vector<pair<long long, long long> > d1;
  vector<pair<long long, long long> > d2;
  d1.push_back(make_pair(0, 0));
  d2.push_back(make_pair(0, 0));
  for (int i = 1; i <= n; i++) {
    cin >> x >> y;
    d1.push_back(make_pair((x1 - x) * (x1 - x) + (y1 - y) * (y1 - y), i));
    d2.push_back(make_pair((x2 - x) * (x2 - x) + (y2 - y) * (y2 - y), i));
  }
  if (n == 1) {
    cout << min((x1 - x) * (x1 - x) + (y1 - y) * (y1 - y),
                (x2 - x) * (x2 - x) + (y2 - y) * (y2 - y));
    return 0;
  }
  vector<bool> used(n + 1, false);
  sort(d1.begin() + 1, d1.end());
  sort(d2.begin() + 1, d2.end());
  long long ans(10e10);
  ans = min(d2[n].first, d1[n].first);
  for (int i = 1; i <= n; i++) {
    r1 = d1[i].first;
    used[d1[i].second] = true;
    for (int j = n; j >= 1; j--) {
      if (used[d2[j].second] == false) {
        r2 = d2[j].first;
        minn(ans, r1 + r2);
        j = 0;
      }
    }
  }
  cout << ans;
}
