Bingo

각 열에 토큰을 하나씩 놓아 행별 토큰 수의 차이를 최소로 만들고, 그다음 토큰이 놓인 칸의 최댓값을 최소로 만든다.

보통7그리디이분 탐색정렬수학아직 제출이 없습니다시간 제한1초메모리 제한512 MB

문제

Consider the following game. You have an integer matrix of size N×MN \times M. Your task is to put MM tokens at some cells of the matrix such as:

  1. each column contains exactly one token;
  2. difference D_rD\_r between the maximum and minimum number of tokens in one row is minimum possible;
  3. among all such token placements, select one such that the maximum value in a matrix cell with a token is minimum possible.

입력

The first line of input contains two integers NN and MM (1N,M1101 \le N, M \le 110). Then matrix a_ia\_i comes: NN lines, each containing MM integers a_i,ja\_{i,j} (1a_i,j1091 \le a\_{i,j} \le 10^9).

출력

Print two integers which describe the placement you found: the minimum possible value of D_rD\_r and the minimum value in a matrix cell with a token.