Language: C++

//import java.util.Scanner;
import java.io.*;

class Main{
    public int inp[] =new int[1000*1000];
    int MAX_VALUE=2147483647;
    int min(int a,int b){return a<b?a:b;}
    int max(int a,int b){return a>b?a:b;}
    int searchmin(int r1,int c1,int r2,int c2,int c){
	int ret=MAX_VALUE;
	for(int i=r1;i<=r2;i++)
	    for(int j=c1;j<=c2;j++)ret=min(ret,inp[i*c+j]);
	return ret;
    }    

    void run(){
	Scanner in = new Scanner();
	int r,c,q;
	while(true){
	    r=in.nextInt();
	    c=in.nextInt();
	    q=in.nextInt();
	    if (r == 0)break;
	    for(int i=0;i<r;i++){
		for(int j=0;j<c;j++){
		    inp[i*c+j]=in.nextInt();
		}
	    }

	    for(int i=0;i<q;i++){
		int r1,r2,c1,c2;
		r1=in.nextInt();
		c1=in.nextInt();
		r2=in.nextInt();
		c2=in.nextInt();
		System.out.println(searchmin(r1,c1,r2,c2,c));
	    }
	}
    }
    public static void main(String args[]){
	Main a = new Main();
	a.run();
    }
}


class Scanner {
    int nextInt() {
        try {
            int c = System.in.read();
            if (c == -1)
                return c;
            while (c != '-' && (c < '0' || '9' < c)) {
                c = System.in.read();
                if (c == -1)
                    return c;
            }
            if (c == '-')
                return -nextInt();
            int res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = System.in.read();
            } while ('0' <= c && c <= '9');
            return res;
        } catch (Exception e) {
            return -1;
        }
    }
 
    long nextLong() {
        try {
            int c = System.in.read();
            if(c==-1)return -1;
            while (c != '-' && (c < '0' || '9' < c)){
                c = System.in.read();
                if(c==-1)return -1;
            }
            if (c == '-')
                return -nextLong();
            long res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = System.in.read();
            } while ('0' <= c && c <= '9');
            return res;
        } catch (Exception e) {
            return -1;
        }
    }
 
    double nextDouble() {
        return Double.parseDouble(next());
    }
 
    String next() {
        try {
            StringBuilder res = new StringBuilder("");
            int c = System.in.read();
            while (Character.isWhitespace(c))
                c = System.in.read();
            do {
                res.append((char) c);
            } while (!Character.isWhitespace(c = System.in.read()));
            return res.toString();
        } catch (Exception e) {
            return null;
        }
    }
 
    String nextLine() {
        try {
            StringBuilder res = new StringBuilder("");
            int c = System.in.read();
            while (c == '\r' || c == '\n')
                c = System.in.read();
            do {
                res.append((char) c);
                c = System.in.read();
            } while (c != '\r' && c != '\n');
            return res.toString();
        } catch (Exception e) {
            return null;
        }
    }
}

Compiler output:
a.cc:2:1: error: 'import' does not name a type
    2 | import java.io.*;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:11: error: expected ':' before 'int'
    5 |     public int inp[] =new int[1000*1000];
      |           ^~~~
      |           :
a.cc:40:11: error: expected ':' before 'static'
   40 |     public static void main(String args[]){
      |           ^~~~~~~
      |           :
a.cc:40:29: error: 'String' has not been declared
   40 |     public static void main(String args[]){
      |                             ^~~~~~
a.cc:5:16: error: flexible array member 'Main::inp' not at end of 'class Main'
    5 |     public int inp[] =new int[1000*1000];
      |                ^~~
a.cc:44:2: error: expected ';' after class definition
   44 | }
      |  ^
      |  ;
a.cc:5:16: error: initializer for flexible array member 'int Main::inp []'
    5 |     public int inp[] =new int[1000*1000];
      |                ^~~
a.cc: In member function 'void Main::run()':
a.cc:17:9: error: 'Scanner' was not declared in this scope
   17 |         Scanner in = new Scanner();
      |         ^~~~~~~
a.cc:20:15: error: 'in' was not declared in this scope; did you mean 'inp'?
   20 |             r=in.nextInt();
      |               ^~
      |               inp
a.cc:36:17: error: 'System' was not declared in this scope
   36 |                 System.out.println(searchmin(r1,c1,r2,c2,c));
      |                 ^~~~~~
a.cc: At global scope:
a.cc:98:5: error: 'String' does not name a type
   98 |     String next() {
      |     ^~~~~~
a.cc:113:5: error: 'String' does not name a type
  113 |     String nextLine() {
      |     ^~~~~~
a.cc:128:2: error: expected ';' after class definition
  128 | }
      |  ^
      |  ;
a.cc: In member function 'int Scanner::nextInt()':
a.cc:50:21: error: 'System' was not declared in this scope
   50 |             int c = System.in.read();
      |                     ^~~~~~
a.cc:67:18: error: 'Exception' does not name a type
   67 |         } catch (Exception e) {
      |                  ^~~~~~~~~
a.cc: In member function 'long int Scanner::nextLong()':
a.cc:74:21: error: 'System' was not declared in this scope
   74 |             int c = System.in.read();
      |                     ^~~~~~
a.cc:89:18: error: 'Exception' does not name a type
   89 |         } catch (Exception e) {
      |                  ^~~~~~~~~
a.cc: In member function 'double Scanner::nextDouble()':
a.cc:95:16: error: 'Double' was not declared in this scope; did you mean 'double'?
   95 |         return Double.parseDouble(next());
      |                ^~~~~~
      |                double
a.cc:95:35: error: 'next' was not declared in this scope; did you mean 'nextInt'?
   95 |         return Double.parseDouble(next());
      |                                   ^~~~
      |                                   nextInt