//make sure to make new file!
import java.io.*;
import java.util.*;

public class B713{
   
   public static BufferedReader f;
   public static PrintWriter out; 
   
   public static void main(String[] args)throws IOException{
      f = new BufferedReader(new InputStreamReader(System.in));
      out = new PrintWriter(System.out);
      
      int n = Integer.parseInt(f.readLine());
      
      
      int l;
      int r;
      int mid;
      int ans;
      
      
      l = 1;
      r = n;
      ans = -1;
      //see if you can draw vertical line between them
      
      while(l <= r){
         mid = l + (r-l)/2;
         if(mid == n) break;
         
         int il = query(1,1,n,mid);
         int ir = query(1,mid+1,n,n);
         
         if(il == 1 && ir == 1){
            ans = mid;
            break;
         }
         
         if(il > ir){
            r = mid-1;
         } else {
            l = mid+1;
         }
      }
      
      int x11 = -1;
      int y11 = -1;
      int x12 = -1;
      int y12 = -1;
      int x21 = -1;
      int y21 = -1;
      int x22 = -1;
      int y22 = -1;
      if(ans == -1){
         //find horizontal line
         l = 1;
         r = n;
         ans = -1;
      
         while(l <= r){
            mid = l + (r-l)/2;
         
         
            int il = query(1,1,mid,n);
            int ir = query(mid+1,1,n,n);
         
            if(il == 1 && ir == 1){
               ans = mid;
               break;
            }
         
            if(il > ir){
               r = mid-1;
            } else {
               l = mid+1;
            }
         }
      
         int bar = ans;
         
                  //find top line of top block
         l = 1;
         r = bar;
         ans = -1;
         while(l <= r){
            mid = l + (r-l)/2;
            
            int i = query(mid,1,bar,n);
            if(i == 1){
               ans = mid;
               l = mid+1;
            } else {
               r = mid-1;
            }
         }
         
         x11 =... Which one is the correct time complexity of the code snippet: constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard?