#include <bits/stdc++.h>
using namespace std;
pair<long long int, int> a[2005];
pair<long long int, int> b[2005];
int main() {
  long long int n, x1, y1, x2, y2;
  cin >> n >> x1 >> y1 >> x2 >> y2;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    a[i] = make_pair((x1 - x) * (x1 - x) + (y1 - y) * (y1 - y), i);
    b[i] = make_pair((x2 - x) * (x2 - x) + (y2 - y) * (y2 - y), i);
  }
  sort(a, a + n);
  sort(b, b + n);
  long long int m = 1e17;
  for (int i = 0; i < n + 1; i++) {
    set<int> s;
    long long int r1 = 0, r2 = 0;
    if (i < n) {
      for (int j = 0; j <= i; j++) {
        s.insert(a[j].second);
        ;
      }
    } else
      r1 = 0;
    if ((int)(s.size()) == n) {
      r1 = a[i].first;
      m = min(r1, m);
    }
    for (int j = 0; j < n; j++) {
      ;
      s.insert(b[j].second);
      if ((int)(s.size()) == n) {
        r1 = a[i].first;
        r2 = b[j].first;
        m = min(r1 + r2, m);
        break;
      }
    }
  }
  cout << m << endl;
  return 0;
}
