//* Problem  : MRAVOJED
//* Origin   : COCI 2008-2009. Contest 1
//* Type     : Judge
//* Date     : 2009.10.10
//* Author   : alt
//* Language : C++
//* Compiler : Microsoft Visual C++ 9.0

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include "testlib.h"

using namespace std;

#define VI vector<int>

#define FOR(i,n) for (int i = 0; i < (int)(n); i++)

#define PB push_back
#define SZ(a) a.size()

int n, m;

vector<string> a;

int f[128][128];

void fill_square(int x, int y, int sz)
{
	if (x < 0 || y < 0 || x + sz > n || y + sz > m)
		quitf(_wa, "Square out of map %d %d %d", x + 1, y + 1, sz);
	FOR(i,sz) FOR(j,sz)
		if (a[x+i][y+j] != 'x')
			quitf(_wa, "No building at cell %d %d", x + i + 1, y + j + 1);
		else
			f[x+i][y+j] = 1;
}

int main(int argc, char *argv[])
{
	registerTestlibCmd(argc, argv);
	
//	ans.close();

	n = inf.readInt();
	m = inf.readInt();
//	inf.nextLine();
	FOR(i,n)
		a.PB(inf.readWord());
//	inf.close();

	int x = ouf.readInt();
	int y = ouf.readInt();
	int sz = ouf.readInt();
	fill_square(x - 1, y - 1, sz);
	x = ouf.readInt();
	y = ouf.readInt();
	sz = ouf.readInt();
	fill_square(x - 1, y - 1, sz);
	
	FOR(i, n) FOR(j, m)
		if (a[i][j] == 'x' && !f[i][j])
			quitf(_wa, "Cell %d %d is not covered", i + 1, j + 1);
	quitf(_ok, "OK");
}
