#!python # -*- coding: utf-8 -*- PRINT_STR = "" def output(y1, x1, y2, x2): global PRINT_STR PRINT_STR += "{} {} {} {}\n".format(y1, x1, y2, x2) def updete(grid, y1, x1, y2, x2): if y1 == y2: y = y1 for x in range(x1, x2 + 1): grid[y][x] *= -1 elif x1 == x2: x = x1 for y in range(y1, y2 + 1): grid[y][x] *= -1 def get_region(N, grid): max_score = 0 max_score_length = 0 max_score_region = (0, 0, 0, 0) for y in range(N): s = 0 length = 0 min_ = 0 max_ = 0 for x in range(N): s += grid[y][x] length += 1 if max_ < s: max_ = s if s < min_: min_ = s max_ = min_ length = 0 score = max_ - min_ if max_score < score: max_score = score max_score_length = length max_score_region = (y, x - length + 1, y, x) elif max_score == score and max_score_length > length: max_score = score max_score_length = length max_score_region = (y, x - length + 1, y, x) for x in range(N): s = 0 length = 0 min_ = 0 max_ = 0 for y in range(N): s += grid[y][x] length += 1 if max_ < s: max_ = s if s < min_: min_ = s max_ = min_ length = 0 score = max_ - min_ if max_score < score: max_score = score max_score_length = length max_score_region = (y - length + 1, x, y, x) elif max_score == score and max_score_length > length: max_score = score max_score_length = length max_score_region = (y - length + 1, x, y, x) return max_score_region def main(): N, K = map(int, input().split()) L = list(map(int, input().split())) grid = [] for i in range(N): grid.append([]) for c in input(): grid[-1].append((c == '1') * 2 - 1) for k in range(K): region = get_region(N, grid) updete(grid, *region) output(*[i + 1 for i in region]) if __name__ == '__main__': main() print(PRINT_STR)