#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <ostream>
using namespace std;

const int MAX_N = 1e5+5;

struct Dir{
    int x,y,dis1,dis2;
    friend ostream& operator<<(ostream &os,Dir d){
        os<<"Dir { x="<<d.x<<" ,y="<<d.y<<" } ";
        return os;
    }
}dirs[MAX_N];
int readInt();
int n;
int ans=INT_MAX;
int l1Max = INT_MIN;

#define DIFF_SQU(a,b)(((a).x-(b).x)*((a).x-(b).x)+((a).y-(b).y)*((a).y-(b).y))

int main(){
    Dir l1,l2;
    l1.x=readInt(),l1.y=readInt(),l2.x=readInt(),l2.y=readInt();
    n=readInt();
    for(int i=1;i<=n;i++){
        auto &di = dirs[i];
        di.x=readInt(),di.y=readInt();
        // l1Max=max(l1Max,(di.x-l1.x)*(di.x-l1.x)+(di.y-l1.y)*(di.y-l1.y));
        di.dis1 = DIFF_SQU(di, l1);
        di.dis2 = DIFF_SQU(di,l2);
    }
    sort(dirs+1,dirs+n+1,[](Dir a,Dir b)->bool{
        return a.dis1<b.dis1;
    });
    int r2=0;
    int ans=dirs[n].dis1;
    for(int i=n-1;i>=1;i--){
        if(dirs[i+1].dis2>r2)r2=dirs[i+1].dis2; //将距离拦截器一更远的那个纳入拦截器2的射程
        ans=min(ans,dirs[i].dis1+r2);
    }

    cout<<ans<<endl;
}

int readInt(){
    int x=0,w=1;
    char ch=0;
    while(!isdigit(ch)){
        if(ch=='-')w=-1;
        ch=getchar();
    }
    while(isdigit(ch)){
        x=x*10+(ch-'0');
        ch=getchar();
    }
    return x*w;
}