#include <bits/stdc++.h>
using namespace std;
unsigned long long distance(int x1, int y1, int x2, int y2) {
  unsigned long long x = fabs(x1 - x2);
  unsigned long long y = fabs(y1 - y2);
  return x * x + y * y;
}
int main() {
  int n;
  vector<pair<int, int> > p;
  vector<pair<unsigned long long, unsigned long long> > dis;
  scanf("%d", &n);
  int x1, y1, x2, y2;
  scanf("%d%d", &x1, &y1);
  scanf("%d%d", &x2, &y2);
  for (int i = 0; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    p.push_back(pair<int, int>(x, y));
  }
  for (int i = 0; i < n; i++) {
    unsigned long long a = distance(x1, y1, p[i].first, p[i].second);
    unsigned long long b = distance(x2, y2, p[i].first, p[i].second);
    dis.push_back(pair<unsigned long long, unsigned long long>(a, b));
  }
  unsigned long long ans;
  for (int j = 0; j < n; j++) {
    unsigned long long r1 = dis[j].first;
    unsigned long long r2 = dis[j].second;
    unsigned long long r11 = 0;
    unsigned long long r22 = 0;
    for (int i = 0; i < n; i++) {
      if (dis[i].second > r2) {
        r11 = max(r11, dis[i].first);
      }
      if (dis[i].first > r1) {
        r22 = max(r22, dis[i].second);
      }
    }
    if (j == 0) {
      ans = min(r11 + r2, r1 + r22);
    } else {
      unsigned long long ans1 = min(r11 + r2, r1 + r22);
      ans = min(ans, ans1);
    }
  }
  printf("%llu\n", ans);
  return 0;
}
