import java.io.PrintWriter import java.util.* import kotlin.math.* fun PrintWriter.solve() { val h = nextInt() val w = nextInt() val u = nextLong() val d = nextLong() val r = nextLong() val l = nextLong() val k = nextLong() val p = nextLong() val xs = nextInt() - 1 val ys = nextInt() - 1 val xt = nextInt() - 1 val yt = nextInt() - 1 val c = Array(h) { nextLine().toCharArray() } var min = Long.MAX_VALUE val pq = PriorityQueue> { x, y -> x.third.compareTo(y.third) } pq.add(Triple(xs, ys, 0)) val visited = Array(h) { BooleanArray(w) { false } } val dx = arrayOf(1, -1, 0, 0) val dy = arrayOf(0, 0, 1, -1) val mc = arrayOf(d, u, r, l) while (pq.isNotEmpty()) { val (x, y, cost) = pq.poll() if (visited[x][y]) continue visited[x][y] = true if (x == xt && y == yt) { min = minOf(min, cost) } for (i in 0 until 4) { val nx = x + dx[i] val ny = y + dy[i] if (nx in 0 until h && ny in 0 until w && !visited[nx][ny]) { if (c[nx][ny] == '.') { pq.add(Triple(nx, ny, cost + mc[i])) } else if (c[nx][ny] == '@') { pq.add(Triple(nx, ny, cost + mc[i] + p)) } } } } println(if (min <= k) "Yes" else "No") } fun main() { val writer = PrintWriter(System.out, false) writer.solve() writer.flush() } // region Scanner private var st = StringTokenizer("") private val br = System.`in`.bufferedReader() fun next(): String { while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine()) return st.nextToken() } fun nextInt() = next().toInt() fun nextLong() = next().toLong() fun nextLine() = br.readLine() fun nextDouble() = next().toDouble() // endregion