import java.util.*; import java.io.*; import java.text.*; //Solution Credits: Taranpreet Singh public class Main{ //SOLUTION BEGIN void pre() throws Exception{} void solve(int TC) throws Exception{ int n = ni(); Point[] p = new Point[n]; for(int i = 0; i< n; i++)p[i] = new Point(nl(), nl()); int S = 200, C = (n+S-1)/S; int[] len = new int[C+1]; for(int i = 2; i<= C; i++)len[i] = len[i>>1]+1; ConvexHull[][] hull = new ConvexHull[len[C]+1][C]; for(int i = 0; i< n; i++){ if(i%S==0)hull[0][i/S] = new ConvexHull(S); hull[0][i/S].add(p[i]); } for(int i = 0; i< C; i++)hull[0][i].refresh(); for(int b = 1; b<= len[C]; b++) for(int i = 0; i + (1<0; q--){ int l = ni()-1, r = ni()-1; if(l/S==r/S || r/S-l/S==1){ ConvexHull h = new ConvexHull(r-l+1); for(int i = l; i<= r; i++)h.add(p[i]); h.refresh(); pn(h.calc()); }else{ ConvexHull h = new ConvexHull(2*S); for(int i = l; i< (l/S+1)*S; i++)h.add(p[i]); for(int i = (r/S)*S; i<= r; i++)h.add(p[i]); int ll = l/S+1, rr = r/S-1; int k = len[rr-ll+1]; ConvexHull hh = new ConvexHull(new ConvexHull(hull[k][ll], h), hull[k][rr-(1<{ long x, y; public Point(long X, long Y){ x=X;y=Y; } public int compareTo(Point p){ if(y!=p.y)return Long.compare(y,p.y); return Long.compare(x, p.x); } long dist(Point p){ return (x-p.x)*(x-p.x)+(y-p.y)*(y-p.y); } long cross(Point q, Point r){ return (q.x-x)*(r.y-y)-(q.y-y)*(r.x-x); } } Point min(Point p1, Point p2){ return p1.compareTo(p2)<0?p1:p2; } int ori(Point p, Point q, Point r){ long v = (q.y-p.y)*(r.x-q.x)-(q.x-p.x)*(r.y-q.y); if(v==0)return 0; return (v<0)?-1:1; } int cmp(Point p, Point p1, Point p2){ int o = ori(p,p1,p2); if(o==0)return Long.compare(p.dist(p1), p.dist(p2)); return o; } class ConvexHull{ Point[] hull;int sz = 0; public ConvexHull(int n){ hull = new Point[n]; } public ConvexHull(ConvexHull a, ConvexHull b){ hull = new Point[a.sz+b.sz]; for(int i = 0; i< a.sz; i++)hull[sz++] = a.hull[i]; for(int i = 0; i< b.sz; i++)hull[sz++] = b.hull[i]; refresh(); } void add(Point p){ hull[sz++] = p; } void refresh(){ Point p = hull[0]; for(int i = 0; i< sz; i++)if(p.compareTo(hull[i])>0)p=hull[i]; final Point q = p; Arrays.sort(hull,0,sz,(Point p1, Point p2) ->cmp(q, p1, p2)); int m = 1; for(int i = 1; i< sz; i++){ while(i1 && ori(hull[top-2], hull[top-1], hull[i])!=-1)top--; hull[top++] = hull[i]; } hull = Arrays.copyOfRange(hull, 0, Math.min(sz, top)); sz = Math.min(sz, top); } long distToLine(Point p, Point q, Point r){ // Shamelessly Copied function // Actually this function returns the area of a triangle. // We can use it because we compare distances to the same line. return Math.abs(p.cross(q,r)); } long calc(){ int p = 0;long ans = 0; for(int i = 0; i< sz; i++){ p = Math.max(p, i+1); while(distToLine(hull[i], hull[(i+1)%sz], hull[p%sz]) < distToLine(hull[i], hull[(i+1)%sz], hull[(p+1)%sz])){ ans = Math.max(ans, hull[i].dist(hull[p%sz])); ans = Math.max(ans, hull[i].dist(hull[(++p)%sz])); } ans = Math.max(ans, hull[i].dist(hull[p%sz])); ans = Math.max(ans, hull[(i+1)%sz].dist(hull[p%sz])); } return ans; } } //SOLUTION END long mod = (long)1e9+7, IINF = (long)4e18; final int INF = (int)2e9, MX = (int)1e6+1; DecimalFormat df = new DecimalFormat("0.000000000000000"); double PI = 3.1415926535897932384626433832792884197169399375105820974944, eps = 1e-8; static boolean multipleTC = false, memory = false; FastReader in;PrintWriter out; void run() throws Exception{ in = new FastReader(); out = new PrintWriter(System.out); int T = (multipleTC)?ni():1; //Solution Credits: Taranpreet Singh pre();for(int i = 1; i<= T; i++)solve(i); out.flush(); out.close(); } public static void main(String[] args) throws Exception{ if(memory)new Thread(null, new Runnable() {public void run(){try{new Main().run();}catch(Exception e){e.printStackTrace();}}}, "1", 1 << 28).start(); else new Main().run(); } long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);} int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);} int bit(long n){return (n==0)?0:(1+bit(n&(n-1)));} void p(Object o){out.print(o);} void pn(Object o){out.println(o);} void pni(Object o){out.println(o);out.flush();} String n(){return in.next();} String nln(){return in.nextLine();} int ni(){return Integer.parseInt(in.next());} long nl(){return Long.parseLong(in.next());} double nd(){return Double.parseDouble(in.next());} class FastReader{ BufferedReader br; StringTokenizer st; public FastReader(){ br = new BufferedReader(new InputStreamReader(System.in)); } public FastReader(String s) throws Exception{ br = new BufferedReader(new FileReader(s)); } String next(){ while (st == null || !st.hasMoreElements()){ try{ st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } } return st.nextToken(); } String nextLine(){ String str = ""; try{ str = br.readLine(); }catch (IOException e){ e.printStackTrace(); } return str; } } }