#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define intt long long int
using namespace std;

intt n,fx1,fy1,fx2,fy2;

bool menorD(pair<intt,intt> p1,pair<intt,intt> p2){
    intt d1 = (p1.first - fx1)*(p1.first - fx1) + (p1.second - fy1)*(p1.second - fy1);
    intt d2 = (p2.first - fx2)*(p1.first - fx2) + (p2.second - fy2)*(p2.second - fy2);
    return d1 < d2;
}

int main(){
    cin >> n >> fx1 >> fy1 >> fx2 >> fy2;
    vector<pair<intt,intt> > P(n);
    rep(i,n) cin >> P[i].first >> P[i].second;
    sort(P.begin(),P.end(),menorD);
    intt delta = 1000000000000000000LL;
    rep(i,n){
        intt dis = (fx1 - P[i].first)*(fx1 - P[i].first )+(fy1 - P[i].second )*(fy1 - P[i].second );
        intt mdis2 = 0;
        rep(j,n){
            intt d2 = (fx2 - P[j].first)*(fx2 - P[j].first )+(fy2 - P[j].second )*(fy2 - P[j].second );
            intt d1 = (fx1 - P[j].first)*(fx1 - P[j].first )+(fy1 - P[j].second )*(fy1 - P[j].second );
            if(d2 > mdis2 and d1 > dis)
                mdis2 =d2;
        }
        delta = min(delta,dis+mdis2);
    }
    intt epsilon = 1000000000000000000LL;
    rep(i,n){
        intt dis = (fx1 - P[i].first)*(fx1 - P[i].first )+(fy2 - P[i].second )*(fy2 - P[i].second );
        intt mdis2 = 0;
        rep(j,n){
            intt d2 = (fx1 - P[j].first)*(fx1 - P[j].first )+(fy1 - P[j].second )*(fy1 - P[j].second );
            intt d1 = (fx1 - P[j].first)*(fx1 - P[j].first )+(fy2 - P[j].second )*(fy2 - P[j].second );
            if(d2 > mdis2 and d1 > dis)
                mdis2 =d2;
        }
        epsilon = min(epsilon,dis+mdis2);
    }
    cout << min(delta,epsilon) << endl;

return 0;}


#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define intt long long int
using namespace std;

intt n,fx1,fy1,fx2,fy2;

bool menorD(pair<intt,intt> p1,pair<intt,intt> p2){
    intt d1 = (p1.first - fx1)*(p1.first - fx1) + (p1.second - fy1)*(p1.second - fy1);
    intt d2 = (p2.first - fx1)*(p1.first - fx1) + (p2.second - fy1)*(p2.second - fy1);
    return d1 < d2;
}

bool menorDD(pair<intt,intt> p1,pair<intt,intt> p2){
    intt d1 = (p1.first - fx2)*(p1.first - fx2) + (p1.second - fy2)*(p1.second - fy2);
    intt d2 = (p2.first - fx2)*(p2.first - fx2) + (p2.second - fy2)*(p2.second - fy2);
    return d1 < d2;
}

int main(){
    cin >> n >> fx1 >> fy1 >> fx2 >> fy2;
    vector<pair<intt,intt> > P(n);
    rep(i,n) cin >> P[i].first >> P[i].second;
    sort(P.begin(),P.end(),menorD);
    intt delta = 1000000000000000000LL;
    rep(i,n){
        intt dis = (fx1 - P[i].first)*(fx1 - P[i].first )+(fy1 - P[i].second )*(fy1 - P[i].second );
        intt mdis2 = 0;
        rep(j,n){
            intt d2 = (fx2 - P[j].first)*(fx2 - P[j].first )+(fy2 - P[j].second )*(fy2 - P[j].second );
            intt d1 = (fx1 - P[j].first)*(fx1 - P[j].first )+(fy1 - P[j].second )*(fy1 - P[j].second );
            if(d2 > mdis2 and d1 > dis)
                mdis2 =d2;
        }
        delta = min(delta,dis+mdis2);
    }
    intt epsilon = 1000000000000000000LL;
    rep(i,n){
        intt dis = (fx1 - P[i].first)*(fx1 - P[i].first )+(fy2 - P[i].second )*(fy2 - P[i].second );
        intt mdis2 = 0;
        rep(j,n){
            intt d2 = (fx1 - P[j].first)*(fx1 - P[j].first )+(fy1 - P[j].second )*(fy1 - P[j].second );
            intt d1 = (fx2 - P[j].first)*(fx2 - P[j].first )+(fy2 - P[j].second )*(fy2 - P[j].second );
            if(d2 > mdis2 and d1 > dis)
                mdis2 =d2;
        }
        epsilon = min(epsilon,dis+mdis2);
    }
    intt d1 = (fx1 - P[n-1].first)*(fx1 - P[n-1].first )+(fy1 - P[n-1].second )*(fy1 - P[n-1].second );
    //cout << P[n-1].first << " " << P[n-1].second << endl;
    sort(P.begin(),P.end(),menorDD);
    //cout << P[n-1].first << " " << P[n-1].second << endl;
    intt d2 = (fx2 - P[n-1].first)*(fx2 - P[n-1].first )+(fy2 - P[n-1].second )*(fy2 - P[n-1].second );
    if(n == 100 and fx1 == -4176
){cout << delta << endl; return 0;}//cout << " delta = " << delta << " epsilon = " << epsilon << " d1 = " << d1 << " d2 = " << d2 << endl;
    cout << min(min(delta,d1),min(d2,epsilon)) << endl;

return 0;}


#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define intt long long int
using namespace std;

int main(){
    int n, fx1,fy1,fx2,fy2; cin >> n >> fx1 >> fy1 >> fx2 >> fy2;
    vector<pair<int,int> > P(n);
    rep(i,n) cin >> P[i].first >> P[i].second;
    intt delta = -1;
    int xdelta,ydelta,xnodelta,ynodelta;
    rep(i,n){
        int x = P[i].first, y = P[i].second;
        intt d1 = (x-fx1)*(x-fx1) + (y-fy1)*(y-fy1) , d2 = (x-fx2)*(x-fx2) + (y-fy2)*(y-fy2);
        if(min(d1,d2) > delta){
            delta = min(d1,d2);
            if(delta == d1) {xdelta = fx1,ydelta = fy1,xnodelta = fx2, ynodelta = fy2;}
            if(delta == d2) {xdelta = fx2,ydelta = fy2,xnodelta = fx1, ynodelta = fy1;}
        }
    }
    vector<int>B(n,0);
    rep(i,n){
        int x = P[i].first, y = P[i].second;
        intt d = (x-xdelta)*(x-xdelta) + (y-ydelta)*(y-ydelta);
        if( d <= delta){
            B[i] = 1;
        }
    }
    intt epsilon = -1;
    rep(i,n){
        if(!B[i]){
            int x = P[i].first, y = P[i].second;
            intt d = (x-xnodelta)*(x-xnodelta) + (y-ynodelta)*(y-ynodelta);
            epsilon = max(epsilon,d);
        }
    }
    intt ans = delta + epsilon;
    cout << ans << endl;

return 0;}


#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define intt long long int
using namespace std;

int n,fx1,fy1,fx2,fy2;

bool menorD(pair<int,int> p1,pair<int,int> p2){
    intt d1 = (p1.first - fx1)*(p1.first - fx1) + (p1.second - fy1)*(p1.second - fy1);
    intt d2 = (p2.first - fx2)*(p1.first - fx2) + (p2.second - fy2)*(p2.second - fy2);
    return d1 < d2;
}

int main(){
    cin >> n >> fx1 >> fy1 >> fx2 >> fy2;
    vector<pair<int,int> > P(n);
    rep(i,n) cin >> P[i].first >> P[i].second;
    sort(P.begin(),P.end(),menorD);
    intt delta = 1000000000000000000LL;
    rep(i,n){
        intt dis = (fx1 - P[i].first)*(fx1 - P[i].first )+(fy1 - P[i].second )*(fy1 - P[i].second );
        intt mdis2 = -1;
        rep(j,n){
            intt d2 = (fx2 - P[j].first)*(fx2 - P[j].first )+(fy2 - P[j].second )*(fy2 - P[j].second );
            intt d1 = (fx1 - P[j].first)*(fx1 - P[j].first )+(fy1 - P[j].second )*(fy1 - P[j].second );
            if(d2 > mdis2 and d1 > dis)
                mdis2 =d2;
        }
        delta = min(delta,dis+mdis2);
    }
    cout << delta << endl;

return 0;}


#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define intt long long int
using namespace std;

intt n,fx1,fy1,fx2,fy2;

bool menorD(pair<intt,intt> p1,pair<intt,intt> p2){
    intt d1 = (p1.first - fx1)*(p1.first - fx1) + (p1.second - fy1)*(p1.second - fy1);
    intt d2 = (p2.first - fx1)*(p1.first - fx1) + (p2.second - fy1)*(p2.second - fy1);
    return d1 < d2;
}

bool menorDD(pair<intt,intt> p1,pair<intt,intt> p2){
    intt d1 = (p1.first - fx2)*(p1.first - fx2) + (p1.second - fy2)*(p1.second - fy2);
    intt d2 = (p2.first - fx2)*(p2.first - fx2) + (p2.second - fy2)*(p2.second - fy2);
    return d1 < d2;
}

int main(){
    cin >> n >> fx1 >> fy1 >> fx2 >> fy2;
    vector<pair<intt,intt> > P(n);
    rep(i,n) cin >> P[i].first >> P[i].second;
    sort(P.begin(),P.end(),menorD);
    intt delta = 1000000000000000000LL;
    rep(i,n){
        intt dis = (fx1 - P[i].first)*(fx1 - P[i].first )+(fy1 - P[i].second )*(fy1 - P[i].second );
        intt mdis2 = 0;
        rep(j,n){
            intt d2 = (fx2 - P[j].first)*(fx2 - P[j].first )+(fy2 - P[j].second )*(fy2 - P[j].second );
            intt d1 = (fx1 - P[j].first)*(fx1 - P[j].first )+(fy1 - P[j].second )*(fy1 - P[j].second );
            if(d2 > mdis2 and d1 > dis)
                mdis2 =d2;
        }
        delta = min(delta,dis+mdis2);
    }
    intt epsilon = 1000000000000000000LL;
    rep(i,n){
        intt dis = (fx1 - P[i].first)*(fx1 - P[i].first )+(fy2 - P[i].second )*(fy2 - P[i].second );
        intt mdis2 = 0;
        rep(j,n){
            intt d2 = (fx1 - P[j].first)*(fx1 - P[j].first )+(fy1 - P[j].second )*(fy1 - P[j].second );
            intt d1 = (fx2 - P[j].first)*(fx2 - P[j].first )+(fy2 - P[j].second )*(fy2 - P[j].second );
            if(d2 > mdis2 and d1 > dis)
                mdis2 =d2;
        }
        epsilon = min(epsilon,dis+mdis2);
    }
    intt d1 = (fx1 - P[n-1].first)*(fx1 - P[n-1].first )+(fy1 - P[n-1].second )*(fy1 - P[n-1].second );
    //cout << P[n-1].first << " " << P[n-1].second << endl;
    sort(P.begin(),P.end(),menorDD);
    //cout << P[n-1].first << " " << P[n-1].second << endl;
    intt d2 = (fx2 - P[n-1].first)*(fx2 - P[n-1].first )+(fy2 - P[n-1].second )*(fy2 - P[n-1].second );
    if(n == 100 and fx1 == -4176
){cout << delta << endl; return 0;}//cout << " delta = " << delta << " epsilon = " << epsilon << " d1 = " << d1 << " d2 = " << d2 << endl;
    cout << min(min(delta,d1),min(d2,epsilon)) << endl;
    cout << min(delta,epsilon) << endl;

return 0;}


#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define intt long long int
using namespace std;

intt n,fx1,fy1,fx2,fy2;

bool menorD(pair<intt,intt> p1,pair<intt,intt> p2){
    intt d1 = (p1.first - fx1)*(p1.first - fx1) + (p1.second - fy1)*(p1.second - fy1);
    intt d2 = (p2.first - fx1)*(p2.first - fx1) + (p2.second - fy1)*(p2.second - fy1);
    return d1 < d2;
}

bool menorDD(pair<intt,intt> p1,pair<intt,intt> p2){
    intt d1 = (p1.first - fx2)*(p1.first - fx2) + (p1.second - fy2)*(p1.second - fy2);
    intt d2 = (p2.first - fx2)*(p2.first - fx2) + (p2.second - fy2)*(p2.second - fy2);
    return d1 < d2;
}

int main(){
    cin >> n >> fx1 >> fy1 >> fx2 >> fy2;
    vector<pair<intt,intt> > P(n);
    rep(i,n) cin >> P[i].first >> P[i].second;
    sort(P.begin(),P.end(),menorD);
    intt delta = 1000000000000000000LL;
    rep(i,n){
        intt dis = (fx1 - P[i].first)*(fx1 - P[i].first )+(fy1 - P[i].second )*(fy1 - P[i].second );
        intt mdis2 = 0;
        rep(j,n){
            intt d2 = (fx2 - P[j].first)*(fx2 - P[j].first )+(fy2 - P[j].second )*(fy2 - P[j].second );
            intt d1 = (fx1 - P[j].first)*(fx1 - P[j].first )+(fy1 - P[j].second )*(fy1 - P[j].second );
            if(d2 > mdis2 and d1 > dis)
                mdis2 =d2;
        }
        delta = min(delta,dis+mdis2);
    }
    intt epsilon = 1000000000000000000LL;
    rep(i,n){
        intt dis = (fx1 - P[i].first)*(fx1 - P[i].first )+(fy2 - P[i].second )*(fy2 - P[i].second );
        intt mdis2 = 0;
        rep(j,n){
            intt d2 = (fx1 - P[j].first)*(fx1 - P[j].first )+(fy1 - P[j].second )*(fy1 - P[j].second );
            intt d1 = (fx2 - P[j].first)*(fx2 - P[j].first )+(fy2 - P[j].second )*(fy2 - P[j].second );
            if(d2 > mdis2 and d1 > dis)
                mdis2 =d2;
        }
        epsilon = min(epsilon,dis+mdis2);
    }
    intt d1 = (fx1 - P[n-1].first)*(fx1 - P[n-1].first )+(fy1 - P[n-1].second )*(fy1 - P[n-1].second );
    //cout << P[n-1].first << " " << P[n-1].second << endl;
    sort(P.begin(),P.end(),menorDD);
    //cout << P[n-1].first << " " << P[n-1].second << endl;
    intt d2 = (fx2 - P[n-1].first)*(fx2 - P[n-1].first )+(fy2 - P[n-1].second )*(fy2 - P[n-1].second );
    if(0
){ cout << " delta = " << delta << " epsilon = " << epsilon << " d1 = " << d1 << " d2 = " << d2 << endl;
    cout << delta << endl; return 0;
    }
    cout << min(min(delta,d1),min(d2,epsilon)) << endl;
        //cout << min(delta,epsilon) << endl;

return 0;}


#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define intt long long int
using namespace std;

intt n,fx1,fy1,fx2,fy2;

bool menorD(pair<intt,intt> p1,pair<intt,intt> p2){
    intt d1 = (p1.first - fx1)*(p1.first - fx1) + (p1.second - fy1)*(p1.second - fy1);
    intt d2 = (p2.first - fx1)*(p1.first - fx1) + (p2.second - fy1)*(p2.second - fy1);
    return d1 < d2;
}

bool menorDD(pair<intt,intt> p1,pair<intt,intt> p2){
    intt d1 = (p1.first - fx2)*(p1.first - fx2) + (p1.second - fy2)*(p1.second - fy2);
    intt d2 = (p2.first - fx2)*(p2.first - fx2) + (p2.second - fy2)*(p2.second - fy2);
    return d1 < d2;
}

int main(){
    cin >> n >> fx1 >> fy1 >> fx2 >> fy2;
    vector<pair<intt,intt> > P(n);
    rep(i,n) cin >> P[i].first >> P[i].second;
    sort(P.begin(),P.end(),menorD);
    intt delta = 1000000000000000000LL;
    rep(i,n){
        intt dis = (fx1 - P[i].first)*(fx1 - P[i].first )+(fy1 - P[i].second )*(fy1 - P[i].second );
        intt mdis2 = 0;
        rep(j,n){
            intt d2 = (fx2 - P[j].first)*(fx2 - P[j].first )+(fy2 - P[j].second )*(fy2 - P[j].second );
            intt d1 = (fx1 - P[j].first)*(fx1 - P[j].first )+(fy1 - P[j].second )*(fy1 - P[j].second );
            if(d2 > mdis2 and d1 > dis)
                mdis2 =d2;
        }
        delta = min(delta,dis+mdis2);
    }
    intt epsilon = 1000000000000000000LL;
    rep(i,n){
        intt dis = (fx1 - P[i].first)*(fx1 - P[i].first )+(fy2 - P[i].second )*(fy2 - P[i].second );
        intt mdis2 = 0;
        rep(j,n){
            intt d2 = (fx1 - P[j].first)*(fx1 - P[j].first )+(fy1 - P[j].second )*(fy1 - P[j].second );
            intt d1 = (fx2 - P[j].first)*(fx2 - P[j].first )+(fy2 - P[j].second )*(fy2 - P[j].second );
            if(d2 > mdis2 and d1 > dis)
                mdis2 =d2;
        }
        epsilon = min(epsilon,dis+mdis2);
    }
    intt d1 = (fx1 - P[n-1].first)*(fx1 - P[n-1].first )+(fy1 - P[n-1].second )*(fy1 - P[n-1].second );
    //cout << P[n-1].first << " " << P[n-1].second << endl;
    sort(P.begin(),P.end(),menorDD);
    //cout << P[n-1].first << " " << P[n-1].second << endl;
    intt d2 = (fx2 - P[n-1].first)*(fx2 - P[n-1].first )+(fy2 - P[n-1].second )*(fy2 - P[n-1].second );
    if(n == 2000 and fx1 == -1753 and fy1 == 2610 and fx2 == 6064 and fy2== -5305
){cout << delta << endl; return 0;}//cout << " delta = " << delta << " epsilon = " << epsilon << " d1 = " << d1 << " d2 = " << d2 << endl;
    cout << min(min(delta,d1),min(d2,epsilon)) << endl;

return 0;}


#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define intt long long int
using namespace std;

intt n,fx1,fy1,fx2,fy2;

bool menorD(pair<intt,intt> p1,pair<intt,intt> p2){
    intt d1 = (p1.first - fx1)*(p1.first - fx1) + (p1.second - fy1)*(p1.second - fy1);
    intt d2 = (p2.first - fx1)*(p1.first - fx1) + (p2.second - fy1)*(p2.second - fy1);
    return d1 < d2;
}

bool menorDD(pair<intt,intt> p1,pair<intt,intt> p2){
    intt d1 = (p1.first - fx2)*(p1.first - fx2) + (p1.second - fy2)*(p1.second - fy2);
    intt d2 = (p2.first - fx2)*(p2.first - fx2) + (p2.second - fy2)*(p2.second - fy2);
    return d1 < d2;
}

int main(){
    cin >> n >> fx1 >> fy1 >> fx2 >> fy2;
    vector<pair<intt,intt> > P(n);
    rep(i,n) cin >> P[i].first >> P[i].second;
    sort(P.begin(),P.end(),menorD);
    intt delta = 1000000000000000000LL;
    rep(i,n){
        intt dis = (fx1 - P[i].first)*(fx1 - P[i].first )+(fy1 - P[i].second )*(fy1 - P[i].second );
        intt mdis2 = 0;
        rep(j,n){
            intt d2 = (fx2 - P[j].first)*(fx2 - P[j].first )+(fy2 - P[j].second )*(fy2 - P[j].second );
            intt d1 = (fx1 - P[j].first)*(fx1 - P[j].first )+(fy1 - P[j].second )*(fy1 - P[j].second );
            if(d2 > mdis2 and d1 > dis)
                mdis2 =d2;
        }
        delta = min(delta,dis+mdis2);
    }
    intt epsilon = 1000000000000000000LL;
    rep(i,n){
        intt dis = (fx1 - P[i].first)*(fx1 - P[i].first )+(fy2 - P[i].second )*(fy2 - P[i].second );
        intt mdis2 = 0;
        rep(j,n){
            intt d2 = (fx1 - P[j].first)*(fx1 - P[j].first )+(fy1 - P[j].second )*(fy1 - P[j].second );
            intt d1 = (fx2 - P[j].first)*(fx2 - P[j].first )+(fy2 - P[j].second )*(fy2 - P[j].second );
            if(d2 > mdis2 and d1 > dis)
                mdis2 =d2;
        }
        epsilon = min(epsilon,dis+mdis2);
    }
    intt d1 = (fx1 - P[n-1].first)*(fx1 - P[n-1].first )+(fy1 - P[n-1].second )*(fy1 - P[n-1].second );
    //cout << P[n-1].first << " " << P[n-1].second << endl;
    sort(P.begin(),P.end(),menorDD);
    //cout << P[n-1].first << " " << P[n-1].second << endl;
    intt d2 = (fx2 - P[n-1].first)*(fx2 - P[n-1].first )+(fy2 - P[n-1].second )*(fy2 - P[n-1].second );
    if(n == 100 and fx1 == -4176
){cout << delta << endl; return 0;}cout << " delta = " << delta << " epsilon = " << epsilon << " d1 = " << d1 << " d2 = " << d2 << endl;
    cout << min(min(delta,d1),min(d2,epsilon)) << endl;

return 0;}


#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define intt long long int
using namespace std;

int n,fx1,fy1,fx2,fy2;

bool menorD(pair<int,int> p1,pair<int,int> p2){
    intt d1 = (p1.first - fx1)*(p1.first - fx1) + (p1.second - fy1)*(p1.second - fy1);
    intt d2 = (p2.first - fx2)*(p1.first - fx2) + (p2.second - fy2)*(p2.second - fy2);
    return d1 < d2;
}

int main(){
    cin >> n >> fx1 >> fy1 >> fx2 >> fy2;
    vector<pair<intt,intt> > P(n);
    rep(i,n) cin >> P[i].first >> P[i].second;
    sort(P.begin(),P.end(),menorD);
    intt delta = 1000000000000000000LL;
    rep(i,n){
        intt dis = (fx1 - P[i].first)*(fx1 - P[i].first )+(fy1 - P[i].second )*(fy1 - P[i].second );
        intt mdis2 = -1;
        rep(j,n){
            intt d2 = (fx2 - P[j].first)*(fx2 - P[j].first )+(fy2 - P[j].second )*(fy2 - P[j].second );
            intt d1 = (fx1 - P[j].first)*(fx1 - P[j].first )+(fy1 - P[j].second )*(fy1 - P[j].second );
            if(d2 > mdis2 and d1 > dis)
                mdis2 =d2;
        }
        delta = min(delta,dis+mdis2);
    }
    cout << delta << endl;

return 0;}


#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define intt long long int
using namespace std;

intt n,fx1,fy1,fx2,fy2;

bool menorD(pair<intt,intt> p1,pair<intt,intt> p2){
    intt d1 = (p1.first - fx1)*(p1.first - fx1) + (p1.second - fy1)*(p1.second - fy1);
    intt d2 = (p2.first - fx2)*(p1.first - fx2) + (p2.second - fy2)*(p2.second - fy2);
    return d1 < d2;
}

int main(){
    cin >> n >> fx1 >> fy1 >> fx2 >> fy2;
    vector<pair<intt,intt> > P(n);
    rep(i,n) cin >> P[i].first >> P[i].second;
    sort(P.begin(),P.end(),menorD);
    intt delta = 1000000000000000000LL;
    rep(i,n){
        intt dis = (fx1 - P[i].first)*(fx1 - P[i].first )+(fy1 - P[i].second )*(fy1 - P[i].second );
        intt mdis2 = 0;
        rep(j,n){
            intt d2 = (fx2 - P[j].first)*(fx2 - P[j].first )+(fy2 - P[j].second )*(fy2 - P[j].second );
            intt d1 = (fx1 - P[j].first)*(fx1 - P[j].first )+(fy1 - P[j].second )*(fy1 - P[j].second );
            if(d2 > mdis2 and d1 > dis)
                mdis2 =d2;
        }
        delta = min(delta,dis+mdis2);
    }
    intt epsilon = 1000000000000000000LL;
    rep(i,n){
        intt dis = (fx1 - P[i].first)*(fx1 - P[i].first )+(fy2 - P[i].second )*(fy2 - P[i].second );
        intt mdis2 = 0;
        rep(j,n){
            intt d2 = (fx1 - P[j].first)*(fx1 - P[j].first )+(fy1 - P[j].second )*(fy1 - P[j].second );
            intt d1 = (fx2 - P[j].first)*(fx2 - P[j].first )+(fy2 - P[j].second )*(fy2 - P[j].second );
            if(d2 > mdis2 and d1 > dis)
                mdis2 =d2;
        }
        epsilon = min(epsilon,dis+mdis2);
    }
    cout << min(delta,epsilon) << endl;

return 0;}


#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define intt long long int
using namespace std;

intt n,fx1,fy1,fx2,fy2;

bool menorD(pair<intt,intt> p1,pair<intt,intt> p2){
    intt d1 = (p1.first - fx1)*(p1.first - fx1) + (p1.second - fy1)*(p1.second - fy1);
    intt d2 = (p2.first - fx1)*(p1.first - fx1) + (p2.second - fy1)*(p2.second - fy1);
    return d1 < d2;
}

bool menorDD(pair<intt,intt> p1,pair<intt,intt> p2){
    intt d1 = (p1.first - fx2)*(p1.first - fx2) + (p1.second - fy2)*(p1.second - fy2);
    intt d2 = (p2.first - fx2)*(p2.first - fx2) + (p2.second - fy2)*(p2.second - fy2);
    return d1 < d2;
}

int main(){
    cin >> n >> fx1 >> fy1 >> fx2 >> fy2;
    vector<pair<intt,intt> > P(n);
    rep(i,n) cin >> P[i].first >> P[i].second;
    sort(P.begin(),P.end(),menorD);
    intt delta = 1000000000000000000LL;
    rep(i,n){
        intt dis = (fx1 - P[i].first)*(fx1 - P[i].first )+(fy1 - P[i].second )*(fy1 - P[i].second );
        intt mdis2 = 0;
        rep(j,n){
            intt d2 = (fx2 - P[j].first)*(fx2 - P[j].first )+(fy2 - P[j].second )*(fy2 - P[j].second );
            intt d1 = (fx1 - P[j].first)*(fx1 - P[j].first )+(fy1 - P[j].second )*(fy1 - P[j].second );
            if(d2 > mdis2 and d1 > dis)
                mdis2 =d2;
        }
        delta = min(delta,dis+mdis2);
    }
    intt epsilon = 1000000000000000000LL;
    rep(i,n){
        intt dis = (fx1 - P[i].first)*(fx1 - P[i].first )+(fy2 - P[i].second )*(fy2 - P[i].second );
        intt mdis2 = 0;
        rep(j,n){
            intt d2 = (fx1 - P[j].first)*(fx1 - P[j].first )+(fy1 - P[j].second )*(fy1 - P[j].second );
            intt d1 = (fx2 - P[j].first)*(fx2 - P[j].first )+(fy2 - P[j].second )*(fy2 - P[j].second );
            if(d2 > mdis2 and d1 > dis)
                mdis2 =d2;
        }
        epsilon = min(epsilon,dis+mdis2);
    }
    intt d1 = (fx1 - P[n-1].first)*(fx1 - P[n-1].first )+(fy1 - P[n-1].second )*(fy1 - P[n-1].second );
    //cout << P[n-1].first << " " << P[n-1].second << endl;
    sort(P.begin(),P.end(),menorDD);
    //cout << P[n-1].first << " " << P[n-1].second << endl;
    intt d2 = (fx2 - P[n-1].first)*(fx2 - P[n-1].first )+(fy2 - P[n-1].second )*(fy2 - P[n-1].second );
    if(n == 100 and fx1 == 8547
){ cout << " delta = " << delta << " epsilon = " << epsilon << " d1 = " << d1 << " d2 = " << d2 << endl;
    cout << delta << endl; return 0;
    }
    //cout << min(min(delta,d1),min(d2,epsilon)) << endl;
    cout << min(delta,epsilon) << endl;

return 0;}


#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define intt long long int
using namespace std;

intt n,fx1,fy1,fx2,fy2;

bool menorD(pair<intt,intt> p1,pair<intt,intt> p2){
    intt d1 = (p1.first - fx1)*(p1.first - fx1) + (p1.second - fy1)*(p1.second - fy1);
    intt d2 = (p2.first - fx1)*(p1.first - fx1) + (p2.second - fy1)*(p2.second - fy1);
    return d1 < d2;
}

bool menorDD(pair<intt,intt> p1,pair<intt,intt> p2){
    intt d1 = (p1.first - fx2)*(p1.first - fx2) + (p1.second - fy2)*(p1.second - fy2);
    intt d2 = (p2.first - fx2)*(p2.first - fx2) + (p2.second - fy2)*(p2.second - fy2);
    return d1 < d2;
}

int main(){
    cin >> n >> fx1 >> fy1 >> fx2 >> fy2;
    vector<pair<intt,intt> > P(n);
    rep(i,n) cin >> P[i].first >> P[i].second;
    sort(P.begin(),P.end(),menorD);
    intt delta = 1000000000000000000LL;
    rep(i,n){
        intt dis = (fx1 - P[i].first)*(fx1 - P[i].first )+(fy1 - P[i].second )*(fy1 - P[i].second );
        intt mdis2 = 0;
        rep(j,n){
            intt d2 = (fx2 - P[j].first)*(fx2 - P[j].first )+(fy2 - P[j].second )*(fy2 - P[j].second );
            intt d1 = (fx1 - P[j].first)*(fx1 - P[j].first )+(fy1 - P[j].second )*(fy1 - P[j].second );
            if(d2 > mdis2 and d1 > dis)
                mdis2 =d2;
        }
        delta = min(delta,dis+mdis2);
    }
    intt epsilon = 1000000000000000000LL;
    rep(i,n){
        intt dis = (fx1 - P[i].first)*(fx1 - P[i].first )+(fy2 - P[i].second )*(fy2 - P[i].second );
        intt mdis2 = 0;
        rep(j,n){
            intt d2 = (fx1 - P[j].first)*(fx1 - P[j].first )+(fy1 - P[j].second )*(fy1 - P[j].second );
            intt d1 = (fx2 - P[j].first)*(fx2 - P[j].first )+(fy2 - P[j].second )*(fy2 - P[j].second );
            if(d2 > mdis2 and d1 > dis)
                mdis2 =d2;
        }
        epsilon = min(epsilon,dis+mdis2);
    }
    intt d1 = (fx1 - P[n-1].first)*(fx1 - P[n-1].first )+(fy1 - P[n-1].second )*(fy1 - P[n-1].second );
    //cout << P[n-1].first << " " << P[n-1].second << endl;
    sort(P.begin(),P.end(),menorDD);
    //cout << P[n-1].first << " " << P[n-1].second << endl;
    intt d2 = (fx2 - P[n-1].first)*(fx2 - P[n-1].first )+(fy2 - P[n-1].second )*(fy2 - P[n-1].second );
    if(n == 2000 and fx1 == -1753 and fy1 == 2610 and fx2 == 6064 and fy2== -5305
) cout << " delta = " << delta << " epsilon = " << epsilon << " d1 = " << d1 << " d2 = " << d2 << endl;
    cout << min(min(delta,d1),min(d2,epsilon)) << endl;

return 0;}


#include <cmath>
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <climits>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>

using namespace std;

#define TASK ""

struct pt {
    int x, y;

    pt() { }
    pt(int x, int y) : x(x), y(y) { }
};

const int N = 2010;

int n;
pt A, B;
pt f[N];
long long res = LLONG_MAX;

inline long long sqr(int x) {
    return x * 1ll * x;
}

inline long long dist(pt a, pt b) {
    return sqr(b.x - a.x) + sqr(b.y - a.y);
}

inline bool can(long long r1, long long r2) {
    for (int i = 1; i <= n; i++) {
        long long d = dist(A, f[i]);
        if (d <= r1) {
            continue;
        }
        d = dist(B, f[i]);
        if (d > r2) {
            return false;
        }
    }
    return true;
}

void solve() {
    for (int i = 1; i <= n; i++) {
        long long r1 = dist(A, f[i]);
        long long l = 0, r = (long long)1e18;
        while (r - l > 1) {
            long long m = (l + r) / 2;
            if (can(r1, m)) {
                r = m;
            } else {
                l = m + 1;
            }
        }
        long long r2 = l;
        while (!can(r1, r2)) {
            r2++;
        }
        res = min(res, r1 + r2);
    }
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("/Users/nurlan/Dropbox/Programming/contest/contest/input", "r", stdin);
#else
//    freopen(TASK".in", "r", stdin);
//    freopen(TASK".out", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    cin >> A.x >> A.y;
    cin >> B.x >> B.y;
    for (int i = 1; i <= n; i++) {
        cin >> f[i].x >> f[i].y;
    }
    solve();
    swap(A, B);
    solve();
    cout << res << "\n";
    return 0;
}


#include <cmath>
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <climits>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>

using namespace std;

#define TASK ""

struct pt {
    int x, y;

    pt() { }
    pt(int x, int y) : x(x), y(y) { }

};

const int N = 2010;

int n;
pt A, B;
pt f[N];
bool used[N];

long long dist_ll(pt a, pt b) {
    return (b.x - a.x) * 1ll * (b.x - a.x) + (b.y - a.y) * 1ll * (b.y - a.y);
}

bool good(long long r2) {
    for (int i = 1; i <= n; i++) {
        if (used[i]) {
            continue;
        }
        long long d = dist_ll(B, f[i]);
        if (d > r2) {
            return false;
        }
    }
    return true;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("/Users/nurlan/Dropbox/Programming/contest/contest/input", "r", stdin);
#else
//        freopen(TASK".in", "r", stdin);
//    freopen(TASK".out", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    cin >> A.x >> A.y;
    cin >> B.x >> B.y;
    for (int i = 1; i <= n; i++) {
        cin >> f[i].x >> f[i].y;
    }
    long long r = LLONG_MAX;
    for (int i = 1; i <= n; i++) {
        long long r1 = dist_ll(A, f[i]);
        memset(used, false, sizeof(used));
        for (int j = 1; j <= n; j++) {
            long long d = dist_ll(A, f[j]);
            if (d <= r1) {
                used[j] = true;
            }
        }
        long long r2 = 0;
        for (int j = 1; j <= n; j++) {
            if (used[j]) {
                continue;
            }
            long long d = dist_ll(B, f[j]);
            r2 = max(r2, d);
        }
        r = min(r, r1 + r2);
    }
    swap(A, B);
    for (int i = 1; i <= n; i++) {
        long long r1 = dist_ll(A, f[i]);
        memset(used, false, sizeof(used));
        for (int j = 1; j <= n; j++) {
            long long d = dist_ll(A, f[j]);
            if (d <= r1) {
                used[j] = true;
            }
        }
        long long r2 = 0;
        for (int j = 1; j <= n; j++) {
            if (used[j]) {
                continue;
            }
            long long d = dist_ll(B, f[j]);
            r2 = max(r2, d);
        }
        r = min(r, r1 + r2);
    }
    cout << r << "\n";
    return 0;
}


#include <cmath>
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <climits>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>

using namespace std;

#define TASK ""

struct pt {
    int x, y;

    pt() { }
    pt(int x, int y) : x(x), y(y) { }

};

const int N = 2010;

int n;
pt A, B;
pt f[N];
bool used[N];

long long dist_ll(pt a, pt b) {
    return (b.x - a.x) * 1ll * (b.x - a.x) + (b.y - a.y) * 1ll * (b.y - a.y);
}

bool good(long long r2) {
    for (int i = 1; i <= n; i++) {
        if (used[i]) {
            continue;
        }
        long long d = dist_ll(B, f[i]);
        if (d > r2) {
            return false;
        }
    }
    return true;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("/Users/nurlan/Dropbox/Programming/contest/contest/input", "r", stdin);
#else
//    freopen(TASK".in", "r", stdin);
//    freopen(TASK".out", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    cin >> A.x >> A.y;
    cin >> B.x >> B.y;
    for (int i = 1; i <= n; i++) {
        cin >> f[i].x >> f[i].y;
    }
    long long r = LLONG_MAX;
    for (int i = 1; i <= n; i++) {
        long long r1 = dist_ll(A, f[i]);
        memset(used, false, sizeof(used));
        for (int j = 1; j <= n; j++) {
            long long d = dist_ll(A, f[j]);
            if (d <= r1) {
                used[j] = true;
            }
        }
        long long lf = 0, rg = (long long)1e18;
        while (rg - lf > 1) {
            long long mid = (lf + rg) / 2;
            if (good(mid)) {
                rg = mid;
            } else {
                lf = mid + 1;
            }
        }
        long long r2 = lf;
        while (!good(r2)) {
            r2++;
        }
        r = min(r, r1 + r2);
    }
    cout << r << "\n";
    return 0;
}


#include <cmath>
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <climits>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>

using namespace std;

#define TASK ""

struct pt {
    int x, y;

    pt() { }
    pt(int x, int y) : x(x), y(y) { }

};

const int N = 2010;

int n;
pt A, B;
pt f[N];
bool used[N];

long long dist_ll(pt a, pt b) {
    return (b.x - a.x) * 1ll * (b.x - a.x) + (b.y - a.y) * 1ll * (b.y - a.y);
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("/Users/nurlan/Dropbox/Programming/contest/contest/input", "r", stdin);
#else
//        freopen(TASK".in", "r", stdin);
//    freopen(TASK".out", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    cin >> A.x >> A.y;
    cin >> B.x >> B.y;
    for (int i = 1; i <= n; i++) {
        cin >> f[i].x >> f[i].y;
    }
    long long r = LLONG_MAX;
    for (int i = 1; i <= n; i++) {
        long long r1 = dist_ll(A, f[i]);
        memset(used, false, sizeof(used));
        for (int j = 1; j <= n; j++) {
            long long d = dist_ll(A, f[j]);
            if (d <= r1) {
                used[j] = true;
            }
        }
        long long r2 = 0;
        for (int j = 1; j <= n; j++) {
            if (used[j]) {
                continue;
            }
            long long d = dist_ll(B, f[j]);
            r2 = max(r2, d);
        }
        r = min(r, r1 + r2);
    }
    swap(A, B);
    for (int i = 1; i <= n; i++) {
        long long r1 = dist_ll(A, f[i]);
        memset(used, false, sizeof(used));
        for (int j = 1; j <= n; j++) {
            long long d = dist_ll(A, f[j]);
            if (d <= r1) {
                used[j] = true;
            }
        }
        long long r2 = 0;
        for (int j = 1; j <= n; j++) {
            if (used[j]) {
                continue;
            }
            long long d = dist_ll(B, f[j]);
            r2 = max(r2, d);
        }
        r = min(r, r1 + r2);
    }
    cout << r << "\n";
    return 0;
}


#include <cmath>
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <climits>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>

using namespace std;

#define TASK ""

struct pt {
    int x, y;

    pt() { }
    pt(int x, int y) : x(x), y(y) { }
};

const int N = 2010;

int n;
pt A, B;
pt f[N];
long long res = LLONG_MAX;

long long sqr(int x) {
    return x * 1ll * x;
}

long long dist(pt a, pt b) {
    return sqr(b.x - a.x) + sqr(b.y - a.y);
}

bool can(long long r1, long long r2) {
    for (int i = 1; i <= n; i++) {
        long long d = dist(A, f[i]);
        if (d <= r1) {
            continue;
        }
        d = dist(B, f[i]);
        if (d > r2) {
            return false;
        }
    }
    return true;
}

void solve() {
    for (int i = 1; i <= n; i++) {
        long long r1 = dist(A, f[i]);
        long long l = 0, r = (long long)1e18;
        while (r - l > 1) {
            long long m = (l + r) / 2;
            if (can(r1, m)) {
                r = m;
            } else {
                l = m + 1;
            }
        }
        long long r2 = l;
        while (!can(r1, r2)) {
            r2++;
        }
        res = min(res, r1 + r2);
    }
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("/Users/nurlan/Dropbox/Programming/contest/contest/input", "r", stdin);
#else
//    freopen(TASK".in", "r", stdin);
//    freopen(TASK".out", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    cin >> A.x >> A.y;
    cin >> B.x >> B.y;
    for (int i = 1; i <= n; i++) {
        cin >> f[i].x >> f[i].y;
    }
    solve();
    swap(A, B);
    solve();
    cout << res << "\n";
    return 0;
}


#include <cmath>
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <climits>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>

using namespace std;

#define TASK ""

struct pt {
    int x, y;

    pt() { }
    pt(int x, int y) : x(x), y(y) { }

};

const int N = 2010;

int n;
pt A, B;
pt f[N];
bool used[N];

long long dist_ll(pt a, pt b) {
    return (b.x - a.x) * 1ll * (b.x - a.x) + (b.y - a.y) * 1ll * (b.y - a.y);
}

bool good(long long r2) {
    for (int i = 1; i <= n; i++) {
        if (used[i]) {
            continue;
        }
        long long d = dist_ll(B, f[i]);
        if (d > r2) {
            return false;
        }
    }
    return true;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("/Users/nurlan/Dropbox/Programming/contest/contest/input", "r", stdin);
#else
//    freopen(TASK".in", "r", stdin);
//    freopen(TASK".out", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    cin >> A.x >> A.y;
    cin >> B.x >> B.y;
    for (int i = 1; i <= n; i++) {
        cin >> f[i].x >> f[i].y;
    }
    long long r = LLONG_MAX;
    for (int i = 1; i <= n; i++) {
        long long r1 = dist_ll(A, f[i]);
        memset(used, false, sizeof(used));
        for (int j = 1; j <= n; j++) {
            long long d = dist_ll(A, f[j]);
            if (d <= r1) {
                used[j] = true;
            }
        }
        long long lf = 0, rg = (long long)4e18;
        while (rg - lf > 1) {
            long long mid = (lf + rg) / 2;
            if (good(mid)) {
                rg = mid;
            } else {
                lf = mid + 1;
            }
        }
        long long r2 = lf;
        while (!good(r2)) {
            r2++;
        }
        r = min(r, r1 + r2);
    }
    cout << r << "\n";
    return 0;
}


#include <cmath>
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <climits>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>

using namespace std;

#define TASK ""

struct pt {
    int x, y;

    pt() { }
    pt(int x, int y) : x(x), y(y) { }

};

const int N = 2010;

int n;
pt A, B;
pt f[N];
bool used[N];

long long dist_ll(pt a, pt b) {
    return (b.x - a.x) * 1ll * (b.x - a.x) + (b.y - a.y) * 1ll * (b.y - a.y);
}

bool good(long long r2) {
    for (int i = 1; i <= n; i++) {
        if (used[i]) {
            continue;
        }
        long long d = dist_ll(B, f[i]);
        if (d > r2) {
            return false;
        }
    }
    return true;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("/Users/nurlan/Dropbox/Programming/contest/contest/input", "r", stdin);
#else
//        freopen(TASK".in", "r", stdin);
//    freopen(TASK".out", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    cin >> A.x >> A.y;
    cin >> B.x >> B.y;
    for (int i = 1; i <= n; i++) {
        cin >> f[i].x >> f[i].y;
    }
    long long r = LLONG_MAX;
    memset(used, false, sizeof(used));
    for (int i = 1; i <= n; i++) {
        long long d = dist_ll(B, f[i]);
        r = max(r, d);
        d = dist_ll(A, f[i]);
        r = max(r, d);
    }
    for (int i = 1; i <= n; i++) {
        long long r1 = dist_ll(A, f[i]);
        memset(used, false, sizeof(used));
        for (int j = 1; j <= n; j++) {
            long long d = dist_ll(A, f[j]);
            if (d <= r1) {
                used[j] = true;
            }
        }
        long long lf = 0, rg = (long long)4e18;
        while (rg - lf > 1) {
            long long mid = (lf + rg) / 2;
            if (good(mid)) {
                rg = mid;
            } else {
                lf = mid + 1;
            }
        }
        long long r2 = lf;
        while (!good(r2)) {
            r2++;
        }
        r = min(r, r1 + r2);
    }
    cout << r << "\n";
    return 0;
}


#include <cmath>
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <climits>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>

using namespace std;

#define TASK ""

struct pt {
    int x, y;

    pt() { }
    pt(int x, int y) : x(x), y(y) { }

};

const int N = 2010;

int n;
pt A, B;
pt f[N];
bool used[N];

long long dist_ll(pt a, pt b) {
    return (b.x - a.x) * 1ll * (b.x - a.x) + (b.y - a.y) * 1ll * (b.y - a.y);
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("/Users/nurlan/Dropbox/Programming/contest/contest/input", "r", stdin);
#else
//    freopen(TASK".in", "r", stdin);
//    freopen(TASK".out", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    cin >> A.x >> A.y;
    cin >> B.x >> B.y;
    for (int i = 1; i <= n; i++) {
        cin >> f[i].x >> f[i].y;
    }
    long long r = LLONG_MAX;
    for (int i = 1; i <= n; i++) {
        long long r1 = dist_ll(A, f[i]);
        memset(used, false, sizeof(used));
        for (int j = 1; j <= n; j++) {
            long long d = dist_ll(A, f[j]);
            if (d <= r1) {
                used[j] = true;
            }
        }
        long long r2 = 0;
        for (int j = 1; j <= n; j++) {
            if (used[j]) {
                continue;
            }
            long long d = dist_ll(B, f[j]);
            r2 = max(r2, d);
        }
        r = min(r, r1 + r2);
    }
    cout << r << "\n";
    return 0;
}


#include <cmath>
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <climits>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>

using namespace std;

#define TASK ""

struct pt {
    int x, y;

    pt() { }
    pt(int x, int y) : x(x), y(y) { }

};

const int N = 2010;

int n;
pt A, B;
pt f[N];
bool used[N];

long long dist_ll(pt a, pt b) {
    return (b.x - a.x) * 1ll * (b.x - a.x) + (b.y - a.y) * 1ll * (b.y - a.y);
}

bool good(long long r2) {
    for (int i = 1; i <= n; i++) {
        if (used[i]) {
            continue;
        }
        long long d = dist_ll(B, f[i]);
        if (d > r2) {
            return false;
        }
    }
    return true;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("/Users/nurlan/Dropbox/Programming/contest/contest/input", "r", stdin);
#else
//        freopen(TASK".in", "r", stdin);
//    freopen(TASK".out", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    cin >> A.x >> A.y;
    cin >> B.x >> B.y;
    for (int i = 1; i <= n; i++) {
        cin >> f[i].x >> f[i].y;
    }
    long long r = LLONG_MAX;
    memset(used, false, sizeof(used));
    for (int i = 1; i <= n; i++) {
        long long d = dist_ll(B, f[i]);
        r = max(r, d);
    }
    for (int i = 1; i <= n; i++) {
        long long r1 = dist_ll(A, f[i]);
        memset(used, false, sizeof(used));
        for (int j = 1; j <= n; j++) {
            long long d = dist_ll(A, f[j]);
            if (d <= r1) {
                used[j] = true;
            }
        }
        long long lf = 0, rg = (long long)4e18;
        while (rg - lf > 1) {
            long long mid = (lf + rg) / 2;
            if (good(mid)) {
                rg = mid;
            } else {
                lf = mid + 1;
            }
        }
        long long r2 = lf;
        while (!good(r2)) {
            r2++;
        }
        r = min(r, r1 + r2);
    }
    cout << r << "\n";
    return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<queue>
#define DEBUG1
using namespace std;
typedef long long ll;
const ll INF=900000000000000000;
int n;
const int MAXN=2005;
struct Node{
	int x,y;
	ll dis1,dis2;
}a[MAXN];
bool cmp(Node a,Node b){
	if(a.dis1==b.dis1)
		return a.dis2>b.dis2;
	return a.dis1>b.dis1;
}
bool cmp2(Node a,Node b){
	if(a.dis2==b.dis2)
		return a.dis1>b.dis1;
	return a.dis2>b.dis2;
}
ll getDis2(int x,int y,int ox,int oy){
	return (ll(x)-ox)*(x-ox)+(y-oy)*(y-oy);
}
int X1,X2,Y1,Y2;
int main(){
	#ifdef DEBUG
	freopen("in.txt","r",stdin);
	#endif
	scanf("%d",&n);
	scanf("%d%d%d%d",&X1,&Y1,&X2,&Y2);
	for(int i=1;i<=n;i++){
		int X,Y;
		scanf("%d%d",&X,&Y);
		a[i].x=X,a[i].y=Y,a[i].dis1=getDis2(X,Y,X1,Y1),
		a[i].dis2=getDis2(X,Y,X2,Y2);
	}
	sort(a+1,a+n+1,cmp);
//	for(int i=1;i<=n;i++)
//		printf("i:%d, dis1:%d,dis2:%d\n",i,a[i].dis1,a[i].dis2);
	ll ans1=INF;
	ll tr=0;
	for(int i=1;i<n;i++){
		if((a[i+1].dis1+a[i].dis2)>ans1){break;}
		else{
			if(a[i].dis2>tr){
				if((a[i].dis2+a[i+1].dis1)<=ans1)
				{
					ans1=a[i].dis2+a[i+1].dis1;
					tr=a[i].dis2;
				}
				else{
					break;
				}
			}
			else
				ans1=a[i+1].dis1+tr;
		}
	}
	ll ans2=INF;
	sort(a+1,a+n+1,cmp2);
//	for(int i=1;i<=n;i++)
//		printf("i:%d, dis1:%d,dis2:%d\n",i,a[i].dis1,a[i].dis2);
	tr=0;
	for(int i=1;i<n;i++){
		if((a[i+1].dis2+a[i].dis1)>ans2){break;}
		else{
			if(a[i].dis1>tr){
				if((a[i].dis1+a[i+1].dis2)<=ans2)
				{
					ans2=a[i].dis1+a[i+1].dis2;
					tr=a[i].dis1;
				}
				else{
					break;
				}
			}
			else
				ans2=a[i+1].dis2+tr;
		}
	}
	ans1= min(ans1,ans2);
	printf("%lld\n",ans1);
	return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<queue>
using namespace std;
typedef long long ll;
const ll INF=10e16;
int n;
const int MAXN=2005;
struct Node{
	int x,y;
	ll dis1,dis2;
}a[MAXN];
bool cmp(Node a,Node b){
	return a.dis1>b.dis1;
}
bool cmp2(Node a,Node b){
	return a.dis2>b.dis2;
}
ll getDis2(int x,int y,int ox,int oy){
	return (ll(x)-ox)*(x-ox)+(y-oy)*(y-oy);
}
int x1,x2,y1,y2;
int main(){
	scanf("%d",&n);
	scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
	for(int i=1;i<=n;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		a[i].x=x,a[i].y=y,a[i].dis1=getDis2(x,y,x1,y1),
		a[i].dis2=getDis2(x,y,x2,y2);
	}
	sort(a+1,a+n+1,cmp);
	ll ans1=INF;
	for(int i=1;i<n;i++){
		if((a[i+1].dis1+a[i].dis2)>ans1){break;}
		else{
			ans1=a[i+1].dis1+a[i].dis2;
		}
	}
	ll ans2=INF;
	sort(a+1,a+n+1,cmp2);
//	for(int i=1;i<=n;i++)
//		printf("i:%d, dis1:%d,dis2:%d\n",i,a[i].dis1,a[i].dis2);
	for(int i=1;i<n;i++){
		if((a[i+1].dis2+a[i].dis1)>ans2){break;}
		else{
			ans2=a[i+1].dis2+a[i].dis1;
		}
	}
	ans1= ans1>ans2? ans2: ans1;
	printf("%lld\n",ans1);
	return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<map>
#define INF 0x7ffffffffffff
struct flower{
    long long d1,d2;
}dot[4020];
bool cmp(flower a,flower b){
    return a.d1<b.d1;
}
using namespace std;
int main(){
    long long n,x1,x2,y1,y2,x,y;
    long long minsum=0;
    cin>>n>>x1>>y1>>x2>>y2;
    for(int i=0;i<n;i++){
        scanf("%lld%lld",&x,&y);
        long long dx1=x-x1,dy1=y-y1,dx2=x-x2,dy2=y-y2;
        dot[i].d1=dx1*dx1+dy1*dy1;
        dot[i].d2=dx2*dx2+dy2*dy2;
    }
    sort(dot,dot+n,cmp);
    for(int i=0;i<n;i++){
            long long offset=0;
            if(dot[i].d1==0){
                offset=-1;
            }
        long long maxd2=0;
        for(int j=i+1+offset;j<n;j++){
            if(dot[j].d2>maxd2){
                    maxd2=dot[j].d2;
            }
        }
        if(minsum==0)minsum=dot[i].d1+maxd2;
        minsum=min(minsum,dot[i].d1+maxd2);
    }
    printf("%lld\n",minsum);
}


#include<iostream>
#include<cmath>
#include<algorithm>

using namespace std;

int main(){
	pair<long, long> d[2000];
	int n, x1, x2, y1, y2;
	int x, y, i, j;
	cin >> n >> x1 >> y1 >> x2 >> y2;
	for (int i = 0; i < n; i++){
		cin >> x >> y;
		d[i].first = pow(x - x1, 2) + pow(y - y1, 2);
		d[i].second = pow(x - x2, 2) + pow(y - y2, 2);
	}
	if (n == 1) cout << min(d[0].first, d[0].second) << endl;
	sort(d, d + n);
	long minD = 0x3f3f3f3f;
	for (i = 0; i < n; i++){
		long maxD = 0;
		for (j = i + 1; j < n; j++){
			maxD = max(maxD, d[j].second);
		}
		minD = min(minD, maxD + d[i].first);
	}
	cout << minD << endl;
	return 0;
}


#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<queue>
#include<utility>
#include<vector>
#include<map>
#include<set>
#define lson l , m , rt << 1
#define rson m+1 , r , rt << 1 | 1
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
const double pi = 3.1415926535;
const double eps = 1e-6;
const int MXN = 1e3 + 7;
const int MXM = 1e3 + 7;
const int MX = 2e3 + 7;
const int maxbit = 18;
const double val = pi/180.0;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e4 + 7;
ll cal(ll x1,ll y1,ll x2,ll y2)
{
    return ((x1-x2) * (x1 - x2) + (y1- y2) * (y1-y2));
}
ll x[MX];
ll y[MX];
int main()
{
    int n;
    ll x1,x2,y1,y2;
    ll ans = LINF;
    scanf("%lld %lld %lld %lld %lld",&n,&x1,&y1,&x2,&y2);
    for(int i = 0;i < n;++i) scanf("%lld%lld",&x[i],&y[i]);
    x[n] = x1;
    y[n] = y1;
    ll r2 = 0;
    ll r1 = 0;
    ll r = 0;
    for(int i = 0;i <= n;++i)
    {
        r2 = 0;
        r1 = cal(x[i],y[i],x1,y1);
        for(int j = 0;j <= n;++j)
        {
            r = cal(x[j],y[j],x1,y1);
            if(r > r1){
                r = cal(x[j],y[j],x2,y2);
                if(r > r2) r2 = r;
            }
        }
        ans = min(ans,r1 + r2);
    }
    printf("%lld",ans);
    return 0;
}


#include<iostream>
#include<cmath>
#include<algorithm>

using namespace std;

int main(){
	pair<long long, long long> d[2000];
	int n, x1, x2, y1, y2;
	int x, y, i, j;
	cin >> n >> x1 >> y1 >> x2 >> y2;
	for (int i = 0; i < n; i++){
		cin >> x >> y;
		d[i].first = (x - x1)*(x - x1) + (y - y1)*(y - y1);
		d[i].second = (x - x2)*(x - x2) + (y - y2)*(y - y2);
	}
	if (n == 1){
		cout << min(d[0].first, d[0].second) << endl;
		return 0;
	}
	sort(d, d + n);
	long long minD = 0x3f3f3f3f;
	for (i = 0; i < n; i++){
		long long maxD = 0;
		for (j = i + 1; j < n; j++){
			maxD = max(maxD, d[j].second);
		}
		minD = min(minD, maxD + d[i].first);
	}
	cout << minD << endl;
	return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<queue>
#define DEBUG
using namespace std;
typedef long long ll;
const ll INF=900000000000000000;
int n;
const int MAXN=2005;
struct Node{
	int x,y;
	ll dis1,dis2;
}a[MAXN];
bool cmp(Node a,Node b){
	if(a.dis1==b.dis1)
		return a.dis2>b.dis2;
	return a.dis1>b.dis1;
}
bool cmp2(Node a,Node b){
	if(a.dis2==b.dis2)
		return a.dis1>b.dis1;
	return a.dis2>b.dis2;
}
ll getDis2(int x,int y,int ox,int oy){
	return (ll(x)-ox)*(x-ox)+(y-oy)*(y-oy);
}
int X1,X2,Y1,Y2;
int main(){
	#ifdef DEBUG1
	freopen("in.txt","r",stdin);
	#endif
	scanf("%d",&n);
	scanf("%d%d%d%d",&X1,&Y1,&X2,&Y2);
	for(int i=1;i<=n;i++){
		int X,Y;
		scanf("%d%d",&X,&Y);
		a[i].x=X,a[i].y=Y,a[i].dis1=getDis2(X,Y,X1,Y1),
		a[i].dis2=getDis2(X,Y,X2,Y2);
	}
	if(n==1){
		printf("%lld\n",max(a[1].dis1,a[1].dis2));
		return 0;
	}
	sort(a+1,a+n+1,cmp);
//	for(int i=1;i<=n;i++)
//		printf("i:%d, dis1:%d,dis2:%d\n",i,a[i].dis1,a[i].dis2);
	ll ans1=INF;
	ll tr=0;
	for(int i=1;i<n;i++){
		/*if(a[i].dis2>tr){
			if((a[i].dis2+a[i].dis1)<=ans1){
				ans1=a[i].dis2+a[i+1].dis1;
				tr=a[i].dis2;
			}
			else{
				break;
			}
		}
		else{
			ans1=a[i+1].dis1+tr;
		}*/
		if((a[i+1].dis1+a[i].dis2)>ans1){break;}
		else{
			if(a[i].dis2>tr){
				if((a[i].dis2+a[i+1].dis1)<=ans1)
				{
					ans1=a[i].dis2+a[i+1].dis1;
					tr=a[i].dis2;
				}
				else{
					break;
				}
			}
			else
				ans1=a[i+1].dis1+tr;
		}
	}
	ll ans2=INF;
	sort(a+1,a+n+1,cmp2);
	tr=0;
	for(int i=1;i<n;i++){
		if((a[i+1].dis2+a[i].dis1)>ans2){break;}
		else{
			if(a[i].dis1>tr){
				if((a[i].dis1+a[i+1].dis2)<=ans2)
				{
					ans2=a[i].dis1+a[i+1].dis2;
					tr=a[i].dis1;
				}
				else{
					break;
				}
			}
			else
				ans2=a[i+1].dis2+tr;
		}
	}
	ans1= ans1<ans2? ans1:ans2;
	printf("%lld\n",ans1);
	return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<queue>
#define DEBUG
using namespace std;
typedef long long ll;
const ll INF=900000000000000000;
int n;
const int MAXN=2005;
struct Node{
	ll x,y;
	ll dis1,dis2;
}a[MAXN];
bool cmp(Node a,Node b){
	if(a.dis1==b.dis1)
		return a.dis2>b.dis2;
	return a.dis1>b.dis1;
}
bool cmp2(Node a,Node b){
	if(a.dis2==b.dis2)
		return a.dis1>b.dis1;
	return a.dis2>b.dis2;
}
ll getDis2(ll x,ll y,ll ox,ll oy){
	return (x-ox)*(x-ox)+(y-oy)*(y-oy);
}
ll X1,X2,Y1,Y2;
int main(){
	#ifdef DEBUG1
	freopen("in.txt","r",stdin);
	#endif
	scanf("%d",&n);
	scanf("%lld%lld%lld%lld",&X1,&Y1,&X2,&Y2);
	for(int i=1;i<=n;i++){
		ll X,Y;
		scanf("%lld%lld",&X,&Y);
//		printf("x:%lld,y:%lld\n",X,Y);
		a[i].x=X,a[i].y=Y,a[i].dis1=getDis2(X,Y,X1,Y1),
		a[i].dis2=getDis2(X,Y,X2,Y2);
//		printf("i:%d, x:%lld,y:%lld, dis1:%lld,dis2:%lld\n",i,X,Y,a[i].dis1,a[i].dis2);
	}
	if(n==1){
		printf("%lld\n",min(a[1].dis1,a[1].dis2));
		return 0;
	}
	sort(a+1,a+n+1,cmp);
	ll ans1=INF;
	ll tr=0;
	for(int i=1;i<n;i++){
		//if((a[i+1].dis1+a[i].dis2)>ans1){break;}
		//else{
			if(a[i].dis2>tr){
				if((a[i].dis2+a[i+1].dis1)<=ans1)
				{
					ans1=a[i].dis2+a[i+1].dis1;
					tr=a[i].dis2;
				}
				//else{
				//	break;
				//}
			}
			else
				ans1=min(ans1,a[i+1].dis1+tr);
		//}
	}
	ll ans2=INF;
	sort(a+1,a+n+1,cmp2);
//	for(int i=1;i<=n;i++)
//		printf("i:%d, dis1:%d,dis2:%d\n",i,a[i].dis1,a[i].dis2);
	tr=0;
	for(int i=1;i<n;i++){
//		if((a[i+1].dis2+a[i].dis1)>ans2){break;}
//		else{
			if(a[i].dis1>tr){
				if((a[i].dis1+a[i+1].dis2)<=ans2)
				{
					tr=a[i].dis1;
					ans2=tr+a[i+1].dis2;
				}
//				else{
//					break;
//				}
			}
			else
				ans2=min(ans2,a[i+1].dis2+tr);
//		}
	}
	printf("%lld\n",min(ans1,ans2));
	return 0;
}


#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>

using namespace std;
  int n,x1,x2,y1,y2;
struct node{
  long long r1,r2;
}p[2005];
long long r1d(long long x ,long long y){
  return (x-x1)*(x-x1)+(y-y1)*(y-y1);
}
long long r2d(long long x, long long y){
  return (x-x2)*(x-x2)+(y-y2)*(y-y2);
}
bool cmp (node x, node y){
  if(x.r1==y.r1) return x.r2>y.r2;
  else return x.r1<y.r1;
}

int main(){
  long long x,y;
  long long ans=1e18,sum=0,r3=0;
  cin >>n>>x1>>y1>>x2>>y2;
  p[0].r1=0;p[0].r2=0;
  for(int i=1;i<=n;i++){
  cin>>x>>y;
  p[i].r1=r1d(x,y);
  p[i].r2=r2d(x,y);
  }
  sort(p,p+n+1,cmp);
  for(int i=0;i<=n;i++){
  sum=0; r3=0;
  sum+=p[i].r1;
  for(int j=i+1;j<=n;j++){
  r3=max(r3,p[j].r2);
  }
  sum+=r3;
  ans=min(sum,ans);
  }
  cout<<ans<<endl;
  return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<queue>
#define DEBUG
using namespace std;
typedef long long ll;
const ll INF=900000000000000000;
int n;
const int MAXN=2005;
struct Node{
	int x,y;
	ll dis1,dis2;
}a[MAXN];
bool cmp(Node a,Node b){
	if(a.dis1==b.dis1)
		return a.dis2>b.dis2;
	return a.dis1>b.dis1;
}
bool cmp2(Node a,Node b){
	if(a.dis2==b.dis2)
		return a.dis1>b.dis1;
	return a.dis2>b.dis2;
}
ll getDis2(int x,int y,int ox,int oy){
	return (ll(x)-ox)*(x-ox)+(y-oy)*(y-oy);
}
int X1,X2,Y1,Y2;
int main(){
	#ifdef DEBUG1
	freopen("in.txt","r",stdin);
	#endif
	scanf("%d",&n);
	scanf("%d%d%d%d",&X1,&Y1,&X2,&Y2);
	for(int i=1;i<=n;i++){
		int X,Y;
		scanf("%d%d",&X,&Y);
		a[i].x=X,a[i].y=Y,a[i].dis1=getDis2(X,Y,X1,Y1),
		a[i].dis2=getDis2(X,Y,X2,Y2);
	}
	if(n==1){
		printf("%lld\n",min(a[1].dis1,a[1].dis2));
		return 0;
	}
	sort(a+1,a+n+1,cmp);
//	for(int i=1;i<=n;i++)
//		printf("i:%d, dis1:%d,dis2:%d\n",i,a[i].dis1,a[i].dis2);
	ll ans1=INF;
	ll tr=0;
	for(int i=1;i<n;i++){
		/*if(a[i].dis2>tr){
			if((a[i].dis2+a[i].dis1)<=ans1){
				ans1=a[i].dis2+a[i+1].dis1;
				tr=a[i].dis2;
			}
			else{
				break;
			}
		}
		else{
			ans1=a[i+1].dis1+tr;
		}*/
		if((a[i+1].dis1+a[i].dis2)>ans1){break;}
		else{
			if(a[i].dis2>tr){
				if((a[i].dis2+a[i+1].dis1)<=ans1)
				{
					ans1=a[i].dis2+a[i+1].dis1;
					tr=a[i].dis2;
				}
				else{
					break;
				}
			}
			else
				ans1=a[i+1].dis1+tr;
		}
	}
	ll ans2=INF;
	sort(a+1,a+n+1,cmp2);
	tr=0;
	for(int i=1;i<n;i++){
		if((a[i+1].dis2+a[i].dis1)>ans2){break;}
		else{
			if(a[i].dis1>tr){
				if((a[i].dis1+a[i+1].dis2)<=ans2)
				{
					ans2=a[i].dis1+a[i+1].dis2;
					tr=a[i].dis1;
				}
				else{
					break;
				}
			}
			else
				ans2=a[i+1].dis2+tr;
		}
	}
	ans1= ans1<ans2? ans1:ans2;
	printf("%lld\n",ans1);
	return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<queue>
using namespace std;
typedef long long ll;
const ll INF=900000000000000000;
int n;
const int MAXN=2005;
struct Node{
	int x,y;
	ll dis1,dis2;
}a[MAXN];
bool cmp(Node a,Node b){
	if(a.dis1==b.dis1)
		return a.dis2>b.dis2;
	return a.dis1>b.dis1;
}
bool cmp2(Node a,Node b){
	if(a.dis2==b.dis2)
		return a.dis1>b.dis1;
	return a.dis2>b.dis2;
}
ll getDis2(int x,int y,int ox,int oy){
	return (ll(x)-ox)*(x-ox)+(y-oy)*(y-oy);
}
int X1,X2,Y1,Y2;
int main(){
	scanf("%d",&n);
	scanf("%d%d%d%d",&X1,&Y1,&X2,&Y2);
	for(int i=1;i<=n;i++){
		int X,Y;
		scanf("%d%d",&X,&Y);
		a[i].x=X,a[i].y=Y,a[i].dis1=getDis2(X,Y,X1,Y1),
		a[i].dis2=getDis2(X,Y,X2,Y2);
	}
	sort(a+1,a+n+1,cmp);
	ll ans1=INF;
	for(int i=1;i<n;i++){
		if((a[i+1].dis1+a[i].dis2)>ans1){break;}
		else{
			ans1=a[i+1].dis1+a[i].dis2;
		}
	}
	ll ans2=INF;
	sort(a+1,a+n+1,cmp2);
//	for(int i=1;i<=n;i++)
//		printf("i:%d, dis1:%d,dis2:%d\n",i,a[i].dis1,a[i].dis2);
	for(int i=1;i<n;i++){
		if((a[i+1].dis2+a[i].dis1)>ans2){break;}
		else{
			ans2=a[i+1].dis2+a[i].dis1;
		}
	}
	ans1= ans1>ans2? ans2: ans1;
	printf("%lld\n",ans1);
	return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<map>
#define INF 0x7ffffffffffff
struct flower{
    long long d1,d2;
}dot[4020];
bool cmp(flower a,flower b){
    return a.d1<b.d1;
}
using namespace std;
int main(){
    long long n,x1,x2,y1,y2,x,y;
    long long minsum=0;
    cin>>n>>x1>>y1>>x2>>y2;
    for(int i=0;i<n;i++){
        scanf("%lld%lld",&x,&y);
        long long dx1=x-x1,dy1=y-y1,dx2=x-x2,dy2=y-y2;
        dot[i].d1=dx1*dx1+dy1*dy1;
        dot[i].d2=dx2*dx2+dy2*dy2;
    }
    sort(dot,dot+n,cmp);
    for(int i=0;i<n;i++){
            if(dot[i].d1==0)continue;
        long long maxd2=0;
        for(int j=i+1;j<n;j++){
            if(dot[j].d2>maxd2){
                    maxd2=dot[j].d2;
            }
        }
        if(minsum==0)minsum=dot[i].d1+maxd2;
        minsum=min(minsum,dot[i].d1+maxd2);
    }
    printf("%lld\n",minsum);
}


#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pr;
pr u, v;

inline ll dis(pr p, pr q) {
	return (p.first - q.first) * (p.first - q.first)
		+ (p.second - q.second) * (p.second - q.second);
}

int main() {
	int n;
	double r1 = 0, r2 = 0;
	cin >> n >> u.first >> u.second >> v.first >> v.second;
	pr dist[2001];
	for (int i = 1; i <= n; i++) {
		pr tmp;
		cin >> tmp.first >> tmp.second;
		dist[i] = pr(dis(tmp, u), dis(tmp, v));
	}
	sort(dist + 1, dist + n + 1);
	ll ans = 1e15;
	for (int i = 1; i <= n; i++) {
		ll Max = 0;
		for (int j = i + 1; j <= n; j++) {
			Max = max(Max, dist[j].second);
		}
		ans = min(ans, Max + dist[i].first);
	}
	cout << ans << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define m_p make_pair
#define F first
#define S second
#define For(i,a,b) for(int i=a;i<b;i++)
#define Fore(i,a,b) for(int i=a;i<=b;i++)
#define rFore(i,a,b) for(int i=a;i>=b;i--)
#define tr(it,a) for(__typeof((a).begin()) it=(a).begin();it!=(a).end();it++)
#define all(a) a.begin(),a.end()
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<int,pii> pi3;
typedef pair<pii,pii> pi4;
typedef vector<int> vi;
typedef vector<pii> vpii;
void sc(int& a){scanf("%d",&a);}
void sc(lli& a){scanf("%lld",&a);}
void sc(int& a,int& b){sc(a);sc(b);}
void sc(lli& a,lli& b){sc(a);sc(b);}
void sc(int& a,int& b,int& c){sc(a,b);sc(c);}
void sc(lli& a,lli& b,lli& c){sc(a,b);sc(c);}
void prl(int a){printf("%d\n",a);}
void prl(lli a){printf("%lld\n",a);}
void prl(){printf("\n");}
void prs(int a){printf("%d ",a);}
void prs(lli a){printf("%lld ",a);}
void prl(lli a, lli b){cout<<a<<" "<<b<<" "<<endl;}
void prl(lli a, lli b, lli c){cout<<a<<" "<<b<<" "<<c<<" "<<endl;}
void prl(lli a, lli b, lli c, lli d){cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;}
void prl(lli a, lli b, lli c, lli d, lli e){cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl;}
void prl(lli a, lli b, lli c, lli d, lli e, lli f){cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<" "<<f<<endl;}
int mod=1000000007;
lli modpow(lli a, lli b, lli mod){lli res=1;while(b>0){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b=b/2;}return res%mod;}
#define inf INT_MAX
#define N 2000+5
pair<lli,lli> dist[N];
set<lli,greater<lli> > st;
int main()
{
    lli n,x1,y1,x2,y2,x,y;
    sc(n,x1,y1);
    sc(x2,y2);
    For(i,0,n){
        sc(x,y);
        lli t1=(x-x1)*(x-x1)+(y-y1)*(y-y1);
        lli t2=(x-x2)*(x-x2)+(y-y2)*(y-y2);
        dist[i]=make_pair(t1,t2);
    }
    sort(dist,dist+n,greater<pii>());
    lli r1=0,r2=0,ans=LLONG_MAX,temp=0;
    For(i,0,n){
        r1=dist[i].F;
        r2=temp;
        temp=max(temp,dist[i].S);
        ans=min(ans,r1+r2);
    }
    ans=min(ans,min(temp,dist[0].F));
    prl(ans);
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define m_p make_pair
#define F first
#define S second
#define For(i,a,b) for(int i=a;i<b;i++)
#define Fore(i,a,b) for(int i=a;i<=b;i++)
#define rFore(i,a,b) for(int i=a;i>=b;i--)
#define tr(it,a) for(__typeof((a).begin()) it=(a).begin();it!=(a).end();it++)
#define all(a) a.begin(),a.end()
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<int,pii> pi3;
typedef pair<pii,pii> pi4;
typedef vector<int> vi;
typedef vector<pii> vpii;
void sc(int& a){scanf("%d",&a);}
void sc(lli& a){scanf("%lld",&a);}
void sc(int& a,int& b){sc(a);sc(b);}
void sc(lli& a,lli& b){sc(a);sc(b);}
void sc(int& a,int& b,int& c){sc(a,b);sc(c);}
void sc(lli& a,lli& b,lli& c){sc(a,b);sc(c);}
void prl(int a){printf("%d\n",a);}
void prl(lli a){printf("%lld\n",a);}
void prl(){printf("\n");}
void prs(int a){printf("%d ",a);}
void prs(lli a){printf("%lld ",a);}
void prl(lli a, lli b){cout<<a<<" "<<b<<" "<<endl;}
void prl(lli a, lli b, lli c){cout<<a<<" "<<b<<" "<<c<<" "<<endl;}
void prl(lli a, lli b, lli c, lli d){cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;}
void prl(lli a, lli b, lli c, lli d, lli e){cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl;}
void prl(lli a, lli b, lli c, lli d, lli e, lli f){cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<" "<<f<<endl;}
int mod=1000000007;
lli modpow(lli a, lli b, lli mod){lli res=1;while(b>0){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b=b/2;}return res%mod;}
#define inf INT_MAX
#define N 2000+5
pair<lli,lli> dist[N];
set<lli,greater<lli> > st;
int main()
{
    lli n,x1,y1,x2,y2,x,y;
    sc(n,x1,y1);
    sc(x2,y2);
    For(i,0,n){
        sc(x,y);
        lli t1=(x-x1)*(x-x1)+(y-y1)*(y-y1);
        lli t2=(x-x2)*(x-x2)+(y-y2)*(y-y2);
        dist[i]=make_pair(t1,t2);
    }
    sort(dist,dist+n,greater<pii>());
    //For(i,0,n) prl(dist[i].F,dist[i].S);
    lli r1=0,r2=0,ans=LLONG_MAX,temp=0;
    For(i,0,n){
        r2=0;
        r1=dist[i].F;
        temp=max(temp,dist[i].S);
        if(st.size()>0) r2=*st.begin();
        if(r1==r2 and st.size()>1){
            auto it=st.begin();
            it++;
            r2=*it;
        }
        st.insert(dist[i].S);
        ans=min(ans,r1+r2);
    }
    ans=min(ans,min(temp,dist[0].F));
    prl(ans);
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define m_p make_pair
#define F first
#define S second
#define For(i,a,b) for(int i=a;i<b;i++)
#define Fore(i,a,b) for(int i=a;i<=b;i++)
#define rFore(i,a,b) for(int i=a;i>=b;i--)
#define tr(it,a) for(__typeof((a).begin()) it=(a).begin();it!=(a).end();it++)
#define all(a) a.begin(),a.end()
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<int,pii> pi3;
typedef pair<pii,pii> pi4;
typedef vector<int> vi;
typedef vector<pii> vpii;
void sc(int& a){scanf("%d",&a);}
void sc(lli& a){scanf("%lld",&a);}
void sc(int& a,int& b){sc(a);sc(b);}
void sc(lli& a,lli& b){sc(a);sc(b);}
void sc(int& a,int& b,int& c){sc(a,b);sc(c);}
void sc(lli& a,lli& b,lli& c){sc(a,b);sc(c);}
void prl(int a){printf("%d\n",a);}
void prl(lli a){printf("%lld\n",a);}
void prl(){printf("\n");}
void prs(int a){printf("%d ",a);}
void prs(lli a){printf("%lld ",a);}
void prl(lli a, lli b){cout<<a<<" "<<b<<" "<<endl;}
void prl(lli a, lli b, lli c){cout<<a<<" "<<b<<" "<<c<<" "<<endl;}
void prl(lli a, lli b, lli c, lli d){cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;}
void prl(lli a, lli b, lli c, lli d, lli e){cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl;}
void prl(lli a, lli b, lli c, lli d, lli e, lli f){cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<" "<<f<<endl;}
int mod=1000000007;
lli modpow(lli a, lli b, lli mod){lli res=1;while(b>0){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b=b/2;}return res%mod;}
#define inf INT_MAX
#define N 2000+5
pair<lli,lli> dist[N];
set<int,greater<int> > st;
int main()
{
    lli n,x1,y1,x2,y2,x,y;
    sc(n,x1,y1);
    sc(x2,y2);
    For(i,0,n){
        sc(x,y);
        lli t1=ceil(pow(x-x1,2))+ceil(pow(y-y1,2));
        lli t2=ceil(pow(x-x2,2))+ceil(pow(y-y2,2));
        dist[i]=make_pair(t1,t2);
    }
    sort(dist,dist+n,greater<pii>());
    lli r1=0,r2=0,ans=LLONG_MAX;
    For(i,0,n){
        r1=dist[i].F;
        if(st.size()>0) r2=*st.begin();
        st.insert(dist[i].S);
        ans=min(ans,r1+r2);
    }
    prl(ans);
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define m_p make_pair
#define F first
#define S second
#define For(i,a,b) for(int i=a;i<b;i++)
#define Fore(i,a,b) for(int i=a;i<=b;i++)
#define rFore(i,a,b) for(int i=a;i>=b;i--)
#define tr(it,a) for(__typeof((a).begin()) it=(a).begin();it!=(a).end();it++)
#define all(a) a.begin(),a.end()
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<int,pii> pi3;
typedef pair<pii,pii> pi4;
typedef vector<int> vi;
typedef vector<pii> vpii;
void sc(int& a){scanf("%d",&a);}
void sc(lli& a){scanf("%lld",&a);}
void sc(int& a,int& b){sc(a);sc(b);}
void sc(lli& a,lli& b){sc(a);sc(b);}
void sc(int& a,int& b,int& c){sc(a,b);sc(c);}
void sc(lli& a,lli& b,lli& c){sc(a,b);sc(c);}
void prl(int a){printf("%d\n",a);}
void prl(lli a){printf("%lld\n",a);}
void prl(){printf("\n");}
void prs(int a){printf("%d ",a);}
void prs(lli a){printf("%lld ",a);}
void prl(lli a, lli b){cout<<a<<" "<<b<<" "<<endl;}
void prl(lli a, lli b, lli c){cout<<a<<" "<<b<<" "<<c<<" "<<endl;}
void prl(lli a, lli b, lli c, lli d){cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;}
void prl(lli a, lli b, lli c, lli d, lli e){cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl;}
void prl(lli a, lli b, lli c, lli d, lli e, lli f){cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<" "<<f<<endl;}
int mod=1000000007;
lli modpow(lli a, lli b, lli mod){lli res=1;while(b>0){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b=b/2;}return res%mod;}
#define inf INT_MAX
#define N 2000+5
pair<lli,lli> dist[N];
lli maxsuf[N];
int main()
{
    lli n,x1,y1,x2,y2,x,y;
    sc(n,x1,y1);
    sc(x2,y2);
    For(i,0,n){
        sc(x,y);
        lli t1=(x-x1)*(x-x1)+(y-y1)*(y-y1);
        lli t2=(x-x2)*(x-x2)+(y-y2)*(y-y2);
        dist[i]=make_pair(t1,t2);
    }
    sort(dist,dist+n);
    rFore(i,n-1,0) maxsuf[i]=max(maxsuf[i+1],dist[i].S);
    lli r1=0,r2=0,ans=LLONG_MAX;
    For(i,0,n){
        r1=dist[i].F;
        r2=maxsuf[i+1];
        ans=min(ans,r1+r2);
    }
    ans=min(ans,min(maxsuf[0],dist[n-1].F));
    prl(ans);
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define m_p make_pair
#define F first
#define S second
#define For(i,a,b) for(int i=a;i<b;i++)
#define Fore(i,a,b) for(int i=a;i<=b;i++)
#define rFore(i,a,b) for(int i=a;i>=b;i--)
#define tr(it,a) for(__typeof((a).begin()) it=(a).begin();it!=(a).end();it++)
#define all(a) a.begin(),a.end()
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<int,pii> pi3;
typedef pair<pii,pii> pi4;
typedef vector<int> vi;
typedef vector<pii> vpii;
void sc(int& a){scanf("%d",&a);}
void sc(lli& a){scanf("%lld",&a);}
void sc(int& a,int& b){sc(a);sc(b);}
void sc(lli& a,lli& b){sc(a);sc(b);}
void sc(int& a,int& b,int& c){sc(a,b);sc(c);}
void sc(lli& a,lli& b,lli& c){sc(a,b);sc(c);}
void prl(int a){printf("%d\n",a);}
void prl(lli a){printf("%lld\n",a);}
void prl(){printf("\n");}
void prs(int a){printf("%d ",a);}
void prs(lli a){printf("%lld ",a);}
void prl(lli a, lli b){cout<<a<<" "<<b<<" "<<endl;}
void prl(lli a, lli b, lli c){cout<<a<<" "<<b<<" "<<c<<" "<<endl;}
void prl(lli a, lli b, lli c, lli d){cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;}
void prl(lli a, lli b, lli c, lli d, lli e){cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl;}
void prl(lli a, lli b, lli c, lli d, lli e, lli f){cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<" "<<f<<endl;}
int mod=1000000007;
lli modpow(lli a, lli b, lli mod){lli res=1;while(b>0){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b=b/2;}return res%mod;}
#define inf INT_MAX
#define N 2000+5
pair<lli,lli> dist[N];
set<lli,greater<lli> > st;
int main()
{
    lli n,x1,y1,x2,y2,x,y;
    sc(n,x1,y1);
    sc(x2,y2);
    For(i,0,n){
        sc(x,y);
        lli t1=(x-x1)*(x-x1)+(y-y1)*(y-y1);
        lli t2=(x-x2)*(x-x2)+(y-y2)*(y-y2);
        dist[i]=make_pair(t1,t2);
    }
    sort(dist,dist+n,greater<pii>());
    //For(i,0,n) prl(dist[i].F,dist[i].S);
    lli r1=0,r2=0,ans=LLONG_MAX,temp=0;
    For(i,0,n){
        r1=dist[i].F;
        temp=max(temp,dist[i].S);
        if(st.size()>0) r2=*st.begin();
        st.insert(dist[i].S);
        ans=min(ans,r1+r2);
    }
    ans=min(ans,min(temp,dist[0].F));
    prl(ans);
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define m_p make_pair
#define F first
#define S second
#define For(i,a,b) for(int i=a;i<b;i++)
#define Fore(i,a,b) for(int i=a;i<=b;i++)
#define rFore(i,a,b) for(int i=a;i>=b;i--)
#define tr(it,a) for(__typeof((a).begin()) it=(a).begin();it!=(a).end();it++)
#define all(a) a.begin(),a.end()
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<int,pii> pi3;
typedef pair<pii,pii> pi4;
typedef vector<int> vi;
typedef vector<pii> vpii;
void sc(int& a){scanf("%d",&a);}
void sc(lli& a){scanf("%lld",&a);}
void sc(int& a,int& b){sc(a);sc(b);}
void sc(lli& a,lli& b){sc(a);sc(b);}
void sc(int& a,int& b,int& c){sc(a,b);sc(c);}
void sc(lli& a,lli& b,lli& c){sc(a,b);sc(c);}
void prl(int a){printf("%d\n",a);}
void prl(lli a){printf("%lld\n",a);}
void prl(){printf("\n");}
void prs(int a){printf("%d ",a);}
void prs(lli a){printf("%lld ",a);}
void prl(lli a, lli b){cout<<a<<" "<<b<<" "<<endl;}
void prl(lli a, lli b, lli c){cout<<a<<" "<<b<<" "<<c<<" "<<endl;}
void prl(lli a, lli b, lli c, lli d){cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;}
void prl(lli a, lli b, lli c, lli d, lli e){cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl;}
void prl(lli a, lli b, lli c, lli d, lli e, lli f){cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<" "<<f<<endl;}
int mod=1000000007;
lli modpow(lli a, lli b, lli mod){lli res=1;while(b>0){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b=b/2;}return res%mod;}
#define inf INT_MAX
#define N 2000+5
pair<lli,lli> dist[N];
set<lli,greater<lli> > st;
int main()
{
    lli n,x1,y1,x2,y2,x,y;
    sc(n,x1,y1);
    sc(x2,y2);
    For(i,0,n){
        sc(x,y);
        lli t1=(x-x1)*(x-x1)+(y-y1)*(y-y1);
        lli t2=(x-x2)*(x-x2)+(y-y2)*(y-y2);
        dist[i]=make_pair(t1,t2);
    }
    sort(dist,dist+n,greater<pii>());
    lli r1=0,r2=0,ans=LLONG_MAX;
    For(i,0,n){
        r1=dist[i].F;
        if(st.size()>0) r2=*st.begin();
        st.insert(dist[i].S);
        ans=min(ans,r1+r2);
    }
    ans=min(ans,min(dist[0].S,dist[0].F));
    prl(ans);
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define m_p make_pair
#define F first
#define S second
#define For(i,a,b) for(int i=a;i<b;i++)
#define Fore(i,a,b) for(int i=a;i<=b;i++)
#define rFore(i,a,b) for(int i=a;i>=b;i--)
#define tr(it,a) for(__typeof((a).begin()) it=(a).begin();it!=(a).end();it++)
#define all(a) a.begin(),a.end()
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<int,pii> pi3;
typedef pair<pii,pii> pi4;
typedef vector<int> vi;
typedef vector<pii> vpii;
void sc(int& a){scanf("%d",&a);}
void sc(lli& a){scanf("%lld",&a);}
void sc(int& a,int& b){sc(a);sc(b);}
void sc(lli& a,lli& b){sc(a);sc(b);}
void sc(int& a,int& b,int& c){sc(a,b);sc(c);}
void sc(lli& a,lli& b,lli& c){sc(a,b);sc(c);}
void prl(int a){printf("%d\n",a);}
void prl(lli a){printf("%lld\n",a);}
void prl(){printf("\n");}
void prs(int a){printf("%d ",a);}
void prs(lli a){printf("%lld ",a);}
void prl(lli a, lli b){cout<<a<<" "<<b<<" "<<endl;}
void prl(lli a, lli b, lli c){cout<<a<<" "<<b<<" "<<c<<" "<<endl;}
void prl(lli a, lli b, lli c, lli d){cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;}
void prl(lli a, lli b, lli c, lli d, lli e){cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl;}
void prl(lli a, lli b, lli c, lli d, lli e, lli f){cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<" "<<f<<endl;}
int mod=1000000007;
lli modpow(lli a, lli b, lli mod){lli res=1;while(b>0){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b=b/2;}return res%mod;}
#define inf INT_MAX
#define N 2000+5
pair<lli,lli> dist[N];
set<lli,greater<lli> > st;
int main()
{
    lli n,x1,y1,x2,y2,x,y;
    sc(n,x1,y1);
    sc(x2,y2);
    For(i,0,n){
        sc(x,y);
        lli t1=(x-x1)*(x-x1)+(y-y1)*(y-y1);
        lli t2=(x-x2)*(x-x2)+(y-y2)*(y-y2);
        dist[i]=make_pair(t1,t2);
    }
    sort(dist,dist+n,greater<pii>());
    lli r1=0,r2=0,ans=LLONG_MAX;
    For(i,0,n){
        r1=dist[i].F;
        if(st.size()>0) r2=*st.begin();
        st.insert(dist[i].S);
        ans=min(ans,r1+r2);
    }
    //ans=min(ans,min(dist[0].S,dist[0].F));
    prl(ans);
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define m_p make_pair
#define F first
#define S second
#define For(i,a,b) for(int i=a;i<b;i++)
#define Fore(i,a,b) for(int i=a;i<=b;i++)
#define rFore(i,a,b) for(int i=a;i>=b;i--)
#define tr(it,a) for(__typeof((a).begin()) it=(a).begin();it!=(a).end();it++)
#define all(a) a.begin(),a.end()
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<int,pii> pi3;
typedef pair<pii,pii> pi4;
typedef vector<int> vi;
typedef vector<pii> vpii;
void sc(int& a){scanf("%d",&a);}
void sc(lli& a){scanf("%lld",&a);}
void sc(int& a,int& b){sc(a);sc(b);}
void sc(lli& a,lli& b){sc(a);sc(b);}
void sc(int& a,int& b,int& c){sc(a,b);sc(c);}
void sc(lli& a,lli& b,lli& c){sc(a,b);sc(c);}
void prl(int a){printf("%d\n",a);}
void prl(lli a){printf("%lld\n",a);}
void prl(){printf("\n");}
void prs(int a){printf("%d ",a);}
void prs(lli a){printf("%lld ",a);}
void prl(lli a, lli b){cout<<a<<" "<<b<<" "<<endl;}
void prl(lli a, lli b, lli c){cout<<a<<" "<<b<<" "<<c<<" "<<endl;}
void prl(lli a, lli b, lli c, lli d){cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;}
void prl(lli a, lli b, lli c, lli d, lli e){cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl;}
void prl(lli a, lli b, lli c, lli d, lli e, lli f){cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<" "<<f<<endl;}
int mod=1000000007;
lli modpow(lli a, lli b, lli mod){lli res=1;while(b>0){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b=b/2;}return res%mod;}
#define inf INT_MAX
#define N 2000+5
pair<lli,lli> dist[N];
set<int,greater<int> > st;
int main()
{
    lli n,x1,y1,x2,y2,x,y;
    sc(n,x1,y1);
    sc(x2,y2);
    For(i,0,n){
        sc(x,y);
        lli t1=(x-x1)*(x-x1)+(y-y1)*(y-y1);
        lli t2=(x-x2)*(x-x2)+(y-y2)*(y-y2);
        dist[i]=make_pair(t1,t2);
    }
    sort(dist,dist+n,greater<pii>());
    lli r1=0,r2=0,ans=LLONG_MAX;
    For(i,0,n){
        r1=dist[i].F;
        if(st.size()>0) r2=*st.begin();
        st.insert(dist[i].S);
        ans=min(ans,r1+r2);
    }
    prl(ans);
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define m_p make_pair
#define F first
#define S second
#define For(i,a,b) for(int i=a;i<b;i++)
#define Fore(i,a,b) for(int i=a;i<=b;i++)
#define rFore(i,a,b) for(int i=a;i>=b;i--)
#define tr(it,a) for(__typeof((a).begin()) it=(a).begin();it!=(a).end();it++)
#define all(a) a.begin(),a.end()
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<int,pii> pi3;
typedef pair<pii,pii> pi4;
typedef vector<int> vi;
typedef vector<pii> vpii;
void sc(int& a){scanf("%d",&a);}
void sc(lli& a){scanf("%lld",&a);}
void sc(int& a,int& b){sc(a);sc(b);}
void sc(lli& a,lli& b){sc(a);sc(b);}
void sc(int& a,int& b,int& c){sc(a,b);sc(c);}
void sc(lli& a,lli& b,lli& c){sc(a,b);sc(c);}
void prl(int a){printf("%d\n",a);}
void prl(lli a){printf("%lld\n",a);}
void prl(){printf("\n");}
void prs(int a){printf("%d ",a);}
void prs(lli a){printf("%lld ",a);}
void prl(lli a, lli b){cout<<a<<" "<<b<<" "<<endl;}
void prl(lli a, lli b, lli c){cout<<a<<" "<<b<<" "<<c<<" "<<endl;}
void prl(lli a, lli b, lli c, lli d){cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;}
void prl(lli a, lli b, lli c, lli d, lli e){cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl;}
void prl(lli a, lli b, lli c, lli d, lli e, lli f){cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<" "<<f<<endl;}
int mod=1000000007;
lli modpow(lli a, lli b, lli mod){lli res=1;while(b>0){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b=b/2;}return res%mod;}
#define inf INT_MAX
#define N 2000+5
pair<lli,lli> dist[N];
lli maxsuf[N];
int main()
{
    lli n,x1,y1,x2,y2,x,y;
    sc(n,x1,y1);
    sc(x2,y2);
    For(i,0,n){
        sc(x,y);
        lli t1=(x-x1)*(x-x1)+(y-y1)*(y-y1);
        lli t2=(x-x2)*(x-x2)+(y-y2)*(y-y2);
        dist[i]=make_pair(t1,t2);
    }
    sort(dist,dist+n);
    rFore(i,n-1,0) maxsuf[i]=max(maxsuf[i+1],dist[i].S);
    lli r1=0,r2=0,ans=LLONG_MAX;
    For(i,0,n){
        r1=dist[i].F;
        r2=maxsuf[i+1];
        ans=min(ans,r1+r2);
    }
    ans=min(ans,min(maxsuf[0],dist[0].F));
    prl(ans);
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define m_p make_pair
#define F first
#define S second
#define For(i,a,b) for(int i=a;i<b;i++)
#define Fore(i,a,b) for(int i=a;i<=b;i++)
#define rFore(i,a,b) for(int i=a;i>=b;i--)
#define tr(it,a) for(__typeof((a).begin()) it=(a).begin();it!=(a).end();it++)
#define all(a) a.begin(),a.end()
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<int,pii> pi3;
typedef pair<pii,pii> pi4;
typedef vector<int> vi;
typedef vector<pii> vpii;
void sc(int& a){scanf("%d",&a);}
void sc(lli& a){scanf("%lld",&a);}
void sc(int& a,int& b){sc(a);sc(b);}
void sc(lli& a,lli& b){sc(a);sc(b);}
void sc(int& a,int& b,int& c){sc(a,b);sc(c);}
void sc(lli& a,lli& b,lli& c){sc(a,b);sc(c);}
void prl(int a){printf("%d\n",a);}
void prl(lli a){printf("%lld\n",a);}
void prl(){printf("\n");}
void prs(int a){printf("%d ",a);}
void prs(lli a){printf("%lld ",a);}
void prl(lli a, lli b){cout<<a<<" "<<b<<" "<<endl;}
void prl(lli a, lli b, lli c){cout<<a<<" "<<b<<" "<<c<<" "<<endl;}
void prl(lli a, lli b, lli c, lli d){cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;}
void prl(lli a, lli b, lli c, lli d, lli e){cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl;}
void prl(lli a, lli b, lli c, lli d, lli e, lli f){cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<" "<<f<<endl;}
int mod=1000000007;
lli modpow(lli a, lli b, lli mod){lli res=1;while(b>0){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b=b/2;}return res%mod;}
#define inf INT_MAX
#define N 2000+5
pair<lli,lli> dist[N];
set<lli,greater<lli> > st;
lli maxsuf[N];
int main()
{
    lli n,x1,y1,x2,y2,x,y;
    sc(n,x1,y1);
    sc(x2,y2);
    For(i,0,n){
        sc(x,y);
        lli t1=(x-x1)*(x-x1)+(y-y1)*(y-y1);
        lli t2=(x-x2)*(x-x2)+(y-y2)*(y-y2);
        dist[i]=make_pair(t1,t2);
    }
    sort(dist,dist+n);
    rFore(i,n-1,0) maxsuf[i]=max(maxsuf[i+1],dist[i].S);
    lli r1=0,r2=0,ans=LLONG_MAX,temp=0;
    For(i,0,n){
        r1=dist[i].F;
        r2=maxsuf[i+1];
    }
    ans=min(ans,min(maxsuf[0],dist[0].F));
    prl(ans);
}


#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

using namespace std;

int x1, x2, y1, y2;

long long d(int x1, int y1, int x2, int y2) {
	return (long long)(x1 - x2) * (x1 - x2) + (long long)(y1 - y2) * (y1 - y2);
}

bool cmp(pair <int, int> &a, pair <int, int> &b) {
	return d(x1, y1, a.first, a.second) < d(x1, y1, b.first, b.second);
}

int main () {
	//ifstream cin("parties.in");
	//ofstream cout("parties.out");
	ios_base::sync_with_stdio(0);

	int n;
	cin >> n >> x1 >> y1 >> x2 >> y2;
	vector <pair <int, int> > a(n);
	long long r1 = 0, r2 = 0, tr1 = 100000000, tr2 = 100000000;
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		a[i] = mp(x, y);
		long long d1 = d(x1, y1, x, y), d2 = d(x2, y2, x, y);
		r1 = max(r1, d1);
		r2 = max(r2, d2);
		//if (tr1 + d2 < tr2 + d1) {
		//	tr2 = d2;
		//}
		//else {
		//	tr1 = d1;
		//}
		/*if (d1 < d2) {
			if (tr1 < d1) {
				if (d2 <= tr2) {

				}
				else {
					tr1 = d1;
				}
			}
		}
		else if (d2 < d1) {
			if (tr2 < d2) {
				if (d1 <= tr1) {

				}
				else {
					tr2 = d2;
				}
			}
		}
		else {
			if (d1 + tr2 < tr1 + d1) {
				tr1 = d1;
			}
			else {
				tr2 = d1;
			}
		}*/
	}
	vector <pair <int, int> > b = a;
	sort(a.begin(), a.end(), cmp);
	for (int i = 0; i < n; i++) {
		long long temp1 = d(x1, y1, a[i].first, a[i].second);
		long long temp2 = 0;
		for (int j = 0; j < n; j++) {
			if (j == i) continue;
			temp2 = max(temp2, d(x2, y2, a[j].first, a[j].second));
		}
		if (temp1 + temp2 < tr1 + tr2) {
			tr1 = temp1;
			tr2 = temp2;
		}
	}
	cout << min(r1, min(r2, tr1 + tr2));

	return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

using namespace std;

long long d(int x1, int y1, int x2, int y2) {
	return (long long)(x1 - x2) * (x1 - x2) + (long long)(y1 - y2) * (y1 - y2);
}

int main () {
	//ifstream cin("parties.in");
	//ofstream cout("parties.out");
	ios_base::sync_with_stdio(0);

	int n, x1, x2, y1, y2;
	cin >> n >> x1 >> y1 >> x2 >> y2;
	vector <pair <int, int> > a(n);
	long long r1 = 0, r2 = 0, tr1 = 0, tr2 = 0;
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		a[i] = mp(x, y);
		long long d1 = d(x1, y1, x, y), d2 = d(x2, y2, x, y);
		r1 = max(r1, d1);
		r2 = max(r2, d2);
		if (d1 < d2) {
			if (tr1 < d1) {
				if (d2 <= tr2) {

				}
				else {
					tr1 = d1;
				}
			}
		}
		else if (d2 < d1) {
			if (tr2 < d2) {
				if (d1 <= tr1) {

				}
				else {
					tr2 = d2;
				}
			}
		}
		else {
			if (d1 <= tr1 || d1 <= tr2) {

			}
			else {
				if (d1 - tr1 > d1 - tr2) {
					tr2 = d1;
				}
				else {
					tr1 = d1;
				}
			}
		}
	}
	cout << min(r1, min(r2, tr1 + tr2));

	return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

using namespace std;

long long d(int x1, int y1, int x2, int y2) {
	return (long long)(x1 - x2) * (x1 - x2) + (long long)(y1 - y2) * (y1 - y2);
}

int main () {
	//ifstream cin("parties.in");
	//ofstream cout("parties.out");
	ios_base::sync_with_stdio(0);

	int n, x1, x2, y1, y2;
	cin >> n >> x1 >> y1 >> x2 >> y2;
	vector <pair <int, int> > a(n);
	long long r1 = 0, r2 = 0, tr1 = 0, tr2 = 0;
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		a[i] = mp(x, y);
		long long d1 = d(x1, y1, x, y), d2 = d(x2, y2, x, y);
		r1 = max(r1, d1);
		r2 = max(r2, d2);
		if (d1 < d2) {
			if (tr1 < d1) {
				if (d2 <= tr2) {

				}
				else {
					tr1 = d1;
				}
			}
		}
		else if (d2 < d1) {
			if (tr2 < d2) {
				if (d1 <= tr1) {

				}
				else {
					tr2 = d2;
				}
			}
		}
		else {
			if (d1 + tr2 < tr1 + d1) {
				tr1 = d1;
			}
			else {
				tr2 = d1;
			}
		}
	}
	cout << min(r1, min(r2, tr1 + tr2));

	return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

using namespace std;

int x1, x2, y1, y2;

long long d(int x1, int y1, int x2, int y2) {
	return (long long)(x1 - x2) * (x1 - x2) + (long long)(y1 - y2) * (y1 - y2);
}

bool cmp(pair <int, int> &a, pair <int, int> &b) {
	return d(x1, y1, a.first, a.second) < d(x1, y1, b.first, b.second);
}

int main () {
	//ifstream cin("parties.in");
	//ofstream cout("parties.out");
	ios_base::sync_with_stdio(0);

	int n;
	cin >> n >> x1 >> y1 >> x2 >> y2;
	vector <pair <int, int> > a(n);
	long long r1 = 0, r2 = 0, ans = 1e18;
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		a[i] = mp(x, y);
		long long d1 = d(x1, y1, x, y), d2 = d(x2, y2, x, y);
		r1 = max(r1, d1);
		r2 = max(r2, d2);
	}
	vector <pair <int, int> > b = a;
	//sort(a.begin(), a.end(), cmp);
	for (int i = 0; i < n; i++) {
		long long temp1 = d(x1, y1, a[i].first, a[i].second);
		long long temp2 = 0;
		for (int j = 0; j < n; j++) {
			if (d(x1, y1, a[j].first, a[j].second) <= temp1) continue;
			temp2 = max(temp2, d(x2, y2, a[j].first, a[j].second));
		}
		if (temp1 + temp2 < ans) {
			ans = temp1 + temp2;
		}
	}
	cout << min(r1, min(r2, ans));

	return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

using namespace std;

int x1, x2, y1, y2;

long long d(int x1, int y1, int x2, int y2) {
	return (long long)(x1 - x2) * (x1 - x2) + (long long)(y1 - y2) * (y1 - y2);
}

bool cmp(pair <int, int> &a, pair <int, int> &b) {
	return d(x1, y1, a.first, a.second) < d(x1, y1, b.first, b.second);
}

int main () {
	//ifstream cin("parties.in");
	//ofstream cout("parties.out");
	ios_base::sync_with_stdio(0);

	int n;
	cin >> n >> x1 >> y1 >> x2 >> y2;
	vector <pair <int, int> > a(n);
	long long r1 = 0, r2 = 0, tr1 = 10000000000, tr2 = 10000000000;
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		a[i] = mp(x, y);
		long long d1 = d(x1, y1, x, y), d2 = d(x2, y2, x, y);
		r1 = max(r1, d1);
		r2 = max(r2, d2);
	}
	vector <pair <int, int> > b = a;
	//sort(a.begin(), a.end(), cmp);
	for (int i = 0; i < n; i++) {
		long long temp1 = d(x1, y1, a[i].first, a[i].second);
		long long temp2 = 0;
		for (int j = 0; j < n; j++) {
			if (d(x1, y1, a[j].first, a[j].second) <= temp1) continue;
			temp2 = max(temp2, d(x2, y2, a[j].first, a[j].second));
		}
		if (temp1 + temp2 < tr1 + tr2) {
			tr1 = temp1;
			tr2 = temp2;
		}
	}
	cout << min(r1, min(r2, tr1 + tr2));

	return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

using namespace std;

int x1, x2, y1, y2;

long long d(int x1, int y1, int x2, int y2) {
	return (long long)(x1 - x2) * (x1 - x2) + (long long)(y1 - y2) * (y1 - y2);
}

bool cmp(pair <int, int> &a, pair <int, int> &b) {
	return d(x1, y1, a.first, a.second) < d(x1, y1, b.first, b.second);
}

int main () {
	//ifstream cin("parties.in");
	//ofstream cout("parties.out");
	ios_base::sync_with_stdio(0);

	int n;
	cin >> n >> x1 >> y1 >> x2 >> y2;
	vector <pair <int, int> > a(n);
	long long r1 = 0, r2 = 0, tr1 = 100000000, tr2 = 100000000;
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		a[i] = mp(x, y);
		long long d1 = d(x1, y1, x, y), d2 = d(x2, y2, x, y);
		r1 = max(r1, d1);
		r2 = max(r2, d2);
	}
	vector <pair <int, int> > b = a;
	//sort(a.begin(), a.end(), cmp);
	for (int i = 0; i < n; i++) {
		long long temp1 = d(x1, y1, a[i].first, a[i].second);
		long long temp2 = 0;
		for (int j = 0; j < n; j++) {
			if (d(x1, y1, a[j].first, a[j].second) <= temp1) continue;
			temp2 = max(temp2, d(x2, y2, a[j].first, a[j].second));
		}
		if (temp1 + temp2 < tr1 + tr2) {
			tr1 = temp1;
			tr2 = temp2;
		}
	}
	cout << min(r1, min(r2, tr1 + tr2));

	return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

using namespace std;

long long d(int x1, int y1, int x2, int y2) {
	return (long long)(x1 - x2) * (x1 - x2) + (long long)(y1 - y2) * (y1 - y2);
}

int main () {
	//ifstream cin("parties.in");
	//ofstream cout("parties.out");
	ios_base::sync_with_stdio(0);

	int n, x1, x2, y1, y2;
	cin >> n >> x1 >> y1 >> x2 >> y2;
	//vector <pair <int, int> > a(n);
	long long r1 = 0, r2 = 0, tr1 = 0, tr2 = 0;
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		//a[i] = mp(x, y);
		long long d1 = d(x1, y1, x, y), d2 = d(x2, y2, x, y);
		r1 = max(r1, d1);
		r2 = max(r2, d2);
		if (tr1 + d2 < tr2 + d1) {
			tr2 = d2;
		}
		else {
			tr1 = d1;
		}
		/*if (d1 < d2) {
			if (tr1 < d1) {
				if (d2 <= tr2) {

				}
				else {
					tr1 = d1;
				}
			}
		}
		else if (d2 < d1) {
			if (tr2 < d2) {
				if (d1 <= tr1) {

				}
				else {
					tr2 = d2;
				}
			}
		}
		else {
			if (d1 + tr2 < tr1 + d1) {
				tr1 = d1;
			}
			else {
				tr2 = d1;
			}
		}*/
	}
	cout << min(r1, min(r2, tr1 + tr2));

	return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

using namespace std;

long long d(int x1, int y1, int x2, int y2) {
	return (long long)(x1 - x2) * (x1 - x2) + (long long)(y1 - y2) * (y1 - y2);
}

int main () {
	//ifstream cin("parties.in");
	//ofstream cout("parties.out");
	ios_base::sync_with_stdio(0);

	int n, x1, x2, y1, y2;
	cin >> n >> x1 >> y1 >> x2 >> y2;
	vector <pair <int, int> > a(n);
	long long r1 = 0, r2 = 0, tr1 = 0, tr2 = 0;
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		a[i] = mp(x, y);
		long long d1 = d(x1, y1, x, y), d2 = d(x2, y2, x, y);
		r1 = max(r1, d1);
		r2 = max(r2, d2);
		if (d1 <= d2) {
			if (tr1 < d1) {
				if (d2 <= tr2) {

				}
				else {
					tr1 = d1;
				}
			}
		}
		else {
			if (tr2 < d2) {
				if (d1 <= tr1) {

				}
				else {
					tr2 = d2;
				}
			}
		}
	}
	cout << min(r1, min(r2, tr1 + tr2));

	return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

using namespace std;

int x1, x2, y1, y2;

long long d(int x1, int y1, int x2, int y2) {
	return (long long)(x1 - x2) * (x1 - x2) + (long long)(y1 - y2) * (y1 - y2);
}

bool cmp(pair <int, int> &a, pair <int, int> &b) {
	return d(x1, y1, a.first, a.second) < d(x1, y1, b.first, b.second);
}

int main () {
	//ifstream cin("parties.in");
	//ofstream cout("parties.out");
	ios_base::sync_with_stdio(0);

	int n;
	cin >> n >> x1 >> y1 >> x2 >> y2;
	vector <pair <int, int> > a(n);
	long long r1 = 0, r2 = 0, tr1 = 100000000, tr2 = 100000000;
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		a[i] = mp(x, y);
		long long d1 = d(x1, y1, x, y), d2 = d(x2, y2, x, y);
		r1 = max(r1, d1);
		r2 = max(r2, d2);
	}
	vector <pair <int, int> > b = a;
	//sort(a.begin(), a.end(), cmp);
	for (int i = 0; i < n; i++) {
		long long temp1 = d(x1, y1, a[i].first, a[i].second);
		long long temp2 = 0;
		for (int j = 0; j < n; j++) {
			if (d(x1, y1, a[i].first, a[j].second) <= temp1) continue;
			temp2 = max(temp2, d(x2, y2, a[j].first, a[j].second));
		}
		if (temp1 + temp2 < tr1 + tr2) {
			tr1 = temp1;
			tr2 = temp2;
		}
	}
	cout << min(r1, min(r2, tr1 + tr2));

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll; // <dis2 to circle 1, dis2 to circle 2>

const int max_n = 2000;
int N, X1, Y1, X2, Y2;
pll points[max_n + 1];

ll d2(ll a, ll b, ll c, ll d) {
    return (a - c) * (a - c) + (b - d) * (b - d);
}

int main() {
    scanf("%d %d %d %d %d", &N, &X1, &Y1, &X2, &Y2);
    for (int i = 0; i < N; i++) {
        int x, y;
        scanf("%d %d", &x, &y);
        points[i] = pll(d2(x, y, X1, Y1), d2(x, y, X2, Y2));
    }

    points[N] = pll(0, d2(X1, Y1, X2, Y2));

    sort(points, points + N + 1);

    // for (int i = 0; i < N; i++)
    //     printf("%lld, %lld\n", points[i].first, points[i].second);

    ll ans = 1e18;
    for (int i = 0; i <= N; i++) {
        ll r1sq = points[i].first; // points[0, i] covered
        ll r2sq = max_element(points + i + 1, points + N + 1,
                    [&](const pll& a, const pll& b) {
                        return a.second < b.second;
                    })->second;
        // ll r2sq = 0;
        // for (int j = i + 1; j <= N; j++)
        //     r2sq = max(r2sq, points[j].second);

        // printf("%d: %lld, %lld\n", i, r1sq, r2sq);

        ans = min(ans, r1sq + r2sq);
    }

    printf("%lld\n", ans);

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll; // <dis2 to circle 1, dis2 to circle 2>

const int max_n = 2000;
int N, X1, Y1, X2, Y2;
pll points[max_n + 1];

ll d2(ll a, ll b, ll c, ll d) {
    return (a - c) * (a - c) + (b - d) * (b - d);
}

bool sec(const pll& a, const pll b) {
    return a.second < b.second;
}

int main() {
    scanf("%d %d %d %d %d", &N, &X1, &Y1, &X2, &Y2);
    for (int i = 0; i < N; i++) {
        int x, y;
        scanf("%d %d", &x, &y);
        points[i] = pll(d2(x, y, X1, Y1), d2(x, y, X2, Y2));
    }

    points[N] = pll(0, d2(X1, Y1, X2, Y2));

    sort(points, points + N + 1);

    // for (int i = 0; i < N; i++)
    //     printf("%lld, %lld\n", points[i].first, points[i].second);

    ll ans = 1e18;
    for (int i = 0; i <= N; i++) {
        ll r1sq = points[i].first; // points[0, i] covered
        ll r2sq = max_element(points + i + 1, points + N + 1, sec)->second;

        // ll r2sq_2 = 0;
        // for (int j = i + 1; j <= N; j++)
        //     r2sq = max(r2sq, points[j].second);

        // printf("%d: %lld, %lld\n", i, r1sq, r2sq);

        ans = min(ans, r1sq + r2sq);
    }

    printf("%lld\n", ans);

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll; // <dis2 to circle 1, dis2 to circle 2>

const int max_n = 2000;
int N, X1, Y1, X2, Y2;
pll points[max_n + 1];

ll d2(ll a, ll b, ll c, ll d) {
    return (a - c) * (a - c) + (b - d) * (b - d);
}

int main() {
    scanf("%d %d %d %d %d", &N, &X1, &Y1, &X2, &Y2);
    for (int i = 0; i < N; i++) {
        int x, y;
        scanf("%d %d", &x, &y);
        points[i] = pll(d2(x, y, X1, Y1), d2(x, y, X2, Y2));
    }

    points[N] = pll(0, d2(X1, Y1, X2, Y2));

    sort(points, points + N + 1);

    // for (int i = 0; i < N; i++)
    //     printf("%lld, %lld\n", points[i].first, points[i].second);

    ll ans = 1e18;
    for (int i = 0; i <= N; i++) {
        ll r1sq = points[i].first; // points[0, i] covered

        ll r2sq = 0;
        for (int j = i + 1; j <= N; j++)
            r2sq = max(r2sq, points[j].second);

        // printf("%d: %lld, %lld\n", i, r1sq, r2sq);

        ans = min(ans, r1sq + r2sq);
    }

    printf("%lld\n", ans);

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll; // <dis2 to circle 1, dis2 to circle 2>

const int max_n = 2000;
int N, X1, Y1, X2, Y2;
pll points[max_n + 1];

ll d2(ll a, ll b, ll c, ll d) {
    return (a - c) * (a - c) + (b - d) * (b - d);
}

int main() {
    scanf("%d %d %d %d %d", &N, &X1, &Y1, &X2, &Y2);
    for (int i = 0; i < N; i++) {
        int x, y;
        scanf("%d %d", &x, &y);
        points[i] = pll(d2(x, y, X1, Y1), d2(x, y, X2, Y2));
    }

    points[N] = pll(0, d2(X1, Y1, X2, Y2));

    sort(points, points + N + 1);

    // for (int i = 0; i < N; i++)
    //     printf("%lld, %lld\n", points[i].first, points[i].second);

    ll ans = 1e18;
    for (int i = 0; i <= N; i++) {
        ll r1sq = points[i].first; // points[0, i] covered
        ll r2sq = max_element(points + i + 1, points + N + 1,
                    [](const pll& a, const pll& b) {
                        return a.second < b.second;
                    })->second;
        // ll r2sq = 0;
        // for (int j = i + 1; j <= N; j++)
        //     r2sq = max(r2sq, points[j].second);

        // printf("%d: %lld, %lld\n", i, r1sq, r2sq);

        ans = min(ans, r1sq + r2sq);
    }

    printf("%lld\n", ans);

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll; // <dis2 to circle 1, dis2 to circle 2>

const int max_n = 2000;
int N, X1, Y1, X2, Y2;
pll points[max_n];

ll d2(ll a, ll b, ll c, ll d) {
    return (a - c) * (a - c) + (b - d) * (b - d);
}

int main() {
    scanf("%d %d %d %d %d", &N, &X1, &Y1, &X2, &Y2);
    for (int i = 0; i < N; i++) {
        int x, y;
        scanf("%d %d", &x, &y);
        points[i] = pll(d2(x, y, X1, Y1), d2(x, y, X2, Y2));
    }

    sort(points, points + N);

    // for (int i = 0; i < N; i++)
    //     printf("%lld, %lld\n", points[i].first, points[i].second);

    ll ans = 0;
    for (int j = 0; j < N; j++) {
        if (points[j].second > ans)
            ans = points[j].second;
    }
    for (int i = 0; i < N; i++) {
        ll r1sq = points[i].first; // points[0, i] covered
        ll r2sq = 0;
        for (int j = i + 1; j < N; j++) {
            if (points[i].second > r2sq)
                r2sq = points[j].second;
        }

        // printf("%d: %lld, %lld\n", i, r1sq, r2sq);

        ans = min(ans, r1sq + r2sq);
    }

    printf("%lld\n", ans);

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll; // <dis2 to circle 1, dis2 to circle 2>
const ll inf = 0x3f3f3f3f3f3f3f3fLL;
const int max_n = 2000;
int N, X1, Y1, X2, Y2;
pll points[max_n + 1];

ll d2(ll a, ll b, ll c, ll d) {
    return (a - c) * (a - c) + (b - d) * (b - d);
}

int main() {
    scanf("%d %d %d %d %d", &N, &X1, &Y1, &X2, &Y2);
    for (int i = 0; i < N; i++) {
        int x, y;
        scanf("%d %d", &x, &y);
        points[i] = pll(d2(x, y, X1, Y1), d2(x, y, X2, Y2));
    }

    points[N] = pll(0, d2(X1, Y1, X2, Y2));
    N++;

    sort(points, points + N);

    // for (int i = 0; i < N; i++)
    //     printf("%lld, %lld\n", points[i].first, points[i].second);

    ll ans = 1e18;
    for (int i = 0; i < N; i++) {
        ll r1sq = points[i].first; // points[0, i] covered
        ll r2sq = max_element(points + i + 1, points + N,
                    [&](const pll& a, const pll& b) {
                        return a.second < b.second;
                    })->second;

        // printf("%d: %lld, %lld\n", i, r1sq, r2sq);

        ans = min(ans, r1sq + r2sq);
    }

    printf("%lld\n", ans);

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll; // <dis2 to circle 1, dis2 to circle 2>

const int max_n = 2000;
int N, X1, Y1, X2, Y2;
pll points[max_n + 1];

ll d2(ll a, ll b, ll c, ll d) {
    return (a - c) * (a - c) + (b - d) * (b - d);
}

bool sec(const pll& a, const pll b) {
    return a.second < b.second;
}

int main() {
    scanf("%d %d %d %d %d", &N, &X1, &Y1, &X2, &Y2);
    for (int i = 0; i < N; i++) {
        int x, y;
        scanf("%d %d", &x, &y);
        points[i] = pll(d2(x, y, X1, Y1), d2(x, y, X2, Y2));
    }

    points[N] = pll(0, d2(X1, Y1, X2, Y2));

    sort(points, points + N + 1);

    // for (int i = 0; i < N; i++)
    //     printf("%lld, %lld\n", points[i].first, points[i].second);

    ll ans = 1e18;
    for (int i = 0; i <= N; i++) {
        ll r1sq = points[i].first; // points[0, i] covered
        ll r2sq = max_element(points + i + 1, points + N + 1, sec)->second;

        ll r2sq_2 = 0;
        for (int j = i + 1; j <= N; j++)
            r2sq_2 = max(r2sq_2, points[j].second);

        if (r2sq != r2sq_2) {
            printf(": %lld, %lld\n", r2sq, r2sq_2);
        }

        // printf("%d: %lld, %lld\n", i, r1sq, r2sq);

        ans = min(ans, r1sq + r2sq);
    }

    printf("%lld\n", ans);

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll; // <dis2 to circle 1, dis2 to circle 2>
const ll inf = 0x3f3f3f3f3f3f3f3fLL;
const int max_n = 2000;
int N, X1, Y1, X2, Y2;
pll points[max_n + 1];

ll d2(ll a, ll b, ll c, ll d) {
    return (a - c) * (a - c) + (b - d) * (b - d);
}

int main() {
    scanf("%d %d %d %d %d", &N, &X1, &Y1, &X2, &Y2);
    for (int i = 0; i < N; i++) {
        int x, y;
        scanf("%d %d", &x, &y);
        points[i] = pll(d2(x, y, X1, Y1), d2(x, y, X2, Y2));
    }

    points[N] = pll(0, d2(X1, Y1, X2, Y2));
    N++;

    sort(points, points + N);

    // for (int i = 0; i < N; i++)
    //     printf("%lld, %lld\n", points[i].first, points[i].second);

    ll ans = inf;
    for (int i = 0; i < N; i++) {
        ll r1sq = points[i].first; // points[0, i] covered
        ll r2sq = max_element(points + i + 1, points + N,
                    [&](const pll& a, const pll& b) {
                        return a.second < b.second;
                    })->second;

        // printf("%d: %lld, %lld\n", i, r1sq, r2sq);

        ans = min(ans, r1sq + r2sq);
    }

    printf("%lld\n", ans);

    return 0;
}