#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; struct point{ int l1,l2; }; point p[100005]; bool cmp(point A,point B) { return A.l1>B.l1; } int main() { freopen("missile.in","r",stdin); freopen("missile.out","w",stdout); int Ax,Bx,Ay,By,n,m1=0,m2=0; cin>>Ax>>Ay>>Bx>>By>>n; for(int i=1;i<=n;i++) { int x,y; cin>>x>>y; p[i].l1=(x-Ax)*(x-Ax)+(y-Ay)*(y-Ay); p[i].l2=(x-Bx)*(x-Bx)+(y-By)*(y-By); } sort(p+1,p+1+n,cmp); int k1=p[1].l1,k2=0; int ans=k1+k2; for(int i=2;i<=n;i++) { k1=p[i].l1 ; k2=max(p[i-1].l2,k2); ans=min(ans,k1+k2); } cout<<ans<<endl; }