#include <bits/stdc++.h>
using namespace std;
long long int n, a, b, c, d, x, y, mini;
vector<long long int> dist[2];
int main(void) {
  cin >> n >> a >> b >> c >> d;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    dist[0].push_back((x - a) * (x - a) + (y - b) * (y - b));
    dist[1].push_back((x - c) * (x - c) + (y - d) * (y - d));
  }
  mini = 1000000000000000000LL;
  for (int i = 0; i < n; i++) {
    long long int maxi = 0;
    for (int j = 0; j < n; j++) {
      if (dist[0][j] > dist[0][i]) maxi = max(maxi, dist[1][j]);
    }
    mini = min(mini, dist[0][i] + maxi);
  }
  sort(dist[0].begin(), dist[0].end());
  sort(dist[1].begin(), dist[1].end());
  mini = min(mini, dist[0][dist[0].size() - 1]);
  mini = min(mini, dist[1][dist[1].size() - 1]);
  cout << mini << endl;
}
