public static int[] search(int[][] m, int x) {
        if (m == null) return null;
        int i = 0, j = m[0].length - 1;
        while (i <= m.length - 1 && j >= 0) {
            if (m[i][j] == x) return new int[] {i, j};
            else if (m[i][j] > x) --j;
            else ++i;
        }
        return new int[] {-1, -1};
    }