import java.io.*;
    public class Main {
        public static void main (String[]args)throws Exception{
        BufferedReader read = new BufferedReader(new InputStreamReader(System.in));


        String[] first_line = read.readLine().split(" ");
        String[] []A = new String [50][];
        String empty;
        int []positions = new int [150];
        int []pancakes = new int [1000];
        String[] ing_bought;
        int []B = new int    [150];
        double lowest;
        int i=0,c;
        int greatest,lowest2;
        int greatest_position;
int u =0;
        while(Integer.parseInt(first_line[0])!=0 && Integer.parseInt(first_line[1])!=0){
            empty = read.readLine();
        if ("0".equals(first_line[0])){
            break;
        }
        ing_bought = read.readLine().split(" ");
        
        for(i=0;i<Integer.parseInt(first_line[1]);i++){
            empty = read.readLine();
            A[i] = read.readLine().split(" ");
        }

        for(i=0,c=0;i<Integer.parseInt(first_line[1]);i++,c=0){
            if ("0".equals(A[i][c])){
                A[i][c] = "1";
            }
            
            lowest2 = Integer.parseInt(ing_bought[c])*10/Integer.parseInt(A[i][c]);
            for(c=1;c<Integer.parseInt(first_line[0]);c++){
                if ("0".equals(A[i][c])){
                    A[i][c] = "1";
                }
                
                if (Integer.parseInt(ing_bought[c])*10/Integer.parseInt(A[i][c]) < lowest2){
                    lowest2 = Integer.parseInt(ing_bought[c])*10/Integer.parseInt(A[i][c]);
                }
            }
            B[i]=lowest2;  
        }

        greatest = (int)B[0];
        greatest_position=1;
        for(i=0;i<Integer.parseInt(first_line[1]);i++){
            if (B[i] > greatest){
                greatest = (int)B[i];
                greatest_position = i+1;
            } 
        }
        if (greatest < 1){
            positions[u]=1;
        }
positions[u]=greatest_position;
pancakes[u]=greatest;
      //  System.out.println(greatest_position + " " + greatest + "\n");
empty = read.readLine();
empty = read.readLine();
empty = read.readLine();

        first_line = read.readLine().split(" ");
        u++;
        }
        for(int l=0;l<u;l++){
            System.out.println(positions[l] + " " + pancakes[l]);
        }
        }
    }
