import heapq def main(): import sys input = sys.stdin.read data = input().split() idx = 0 H = int(data[idx]) W = int(data[idx+1]) Y = int(data[idx+2]) - 1 # converting to 0-based index X = int(data[idx+3]) - 1 idx +=4 A = [] for i in range(H): row = list(map(int, data[idx:idx+W])) A.append(row) idx += W current_power = A[Y][X] visited = [[False for _ in range(W)] for _ in range(H)] visited[Y][X] = True remaining = H * W - 1 # exclude starting position heap = [] # Check initial position's neighbors directions = [(-1, 0), (1, 0), (0, -1), (0, 1)] for dy, dx in directions: ny = Y + dy nx = X + dx if 0 <= ny < H and 0 <= nx < W and not visited[ny][nx]: heapq.heappush(heap, (A[ny][nx], ny, nx)) while remaining > 0: if not heap: print("No") return attack, y, x = heapq.heappop(heap) if visited[y][x]: continue if attack > current_power: print("No") return current_power += attack visited[y][x] = True remaining -= 1 # Check neighbors of the current cell for dy, dx in directions: ny = y + dy nx = x + dx if 0 <= ny < H and 0 <= nx < W and not visited[ny][nx]: heapq.heappush(heap, (A[ny][nx], ny, nx)) print("Yes") if __name__ == "__main__": main()