#!/usr/bin/env python3 # from typing import * import sys import io import math import collections import decimal import itertools import bisect import heapq def input(): return sys.stdin.readline()[:-1] # sys.setrecursionlimit(1000000) # _INPUT = """2 2 # 0 0 0 0 1 1 # 1 1 2 2 # .@ # #. # """ # sys.stdin = io.StringIO(_INPUT) INF = 10**20 YES = 'Yes' NO = 'No' def solve(): dist = [[INF] * W for _ in range(H)] hq = [] dist[StartY][StartX] = 0 heapq.heappush(hq, (0, StartX, StartY)) while hq: d, x, y = heapq.heappop(hq) if (x, y) == (GoalX, GoalY): return d for x1, y1, d1 in [(x-1, y, d+L), (x+1, y, d+R), (x, y-1, U), (x, y+1, D)]: if not(0 <= x1 < W and 0 <= y1 < H) or C[y1][x1] == '#': continue elif C[y1][x1] == '@': d1 += P if d1 < dist[y1][x1]: dist[y1][x1] = d1 heapq.heappush(hq, (d1, x1, y1)) return INF H, W = map(int, input().split()) U, D, R, L, K, P = map(int, input().split()) StartX, StartY, GoalX, GoalY = map(lambda x: int(x)-1, input().split()) C = [input() for _ in range(H)] cost = solve() if cost <= K: print('Yes') else: print('No')