#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const int N = 2 * 1e6 + 10;
ll res;
ll a[N];
std::map<pair<ll, pair<ll, ll>>, ll> mp, mpp;
void solve() {
  ll n, x, y, xx, yy;
  cin >> n >> x >> y >> xx >> yy;
  mp[{0, {x, y}}]++;
  mpp[{0, {xx, yy}}]++;
  for (int i = 0; i < n; ++i) {
    ll d, dd, a, b;
    cin >> a >> b;
    d = (x - a) * (x - a) + (y - b) * (y - b);
    dd = (xx - a) * (xx - a) + (yy - b) * (yy - b);
    mp[{d, {a, b}}]++;
    mpp[{dd, {a, b}}]++;
  }
  ll mn = inf;
  for (auto i : mp) {
    res = 0;
    if (i.first.first == 0) {
      auto itr = mpp.rbegin();
      res += (*itr).first.first;
    } else {
      res += i.first.first;
      ll d = (xx - i.first.second.first) * (xx - i.first.second.first) +
             (yy - i.first.second.second) * (yy - i.first.second.second);
      mpp.erase({d, {i.first.second.first, i.first.second.second}});
      auto itr = mpp.rbegin();
      res += (*itr).first.first;
    }
    mn = min(res, mn);
  }
  cout << mn;
}
int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  ll t = 1;
  while (t--) {
    solve();
  }
}
