import java.io.*;
import java.util.*;
import java.math.*;

public class cylon_ab implements Runnable {

	final int MAXN = 20;
	final int MAXM = 20;
	final int MAXV = 1000;
	
	
	private void solve() throws IOException {
		int n = in.nextInt();
		assert 1 <= n && n <= MAXN;
		int m = in.nextInt();
		assert 1 <= m && m <= MAXM;
		long[][] a = new long[n][m];
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < m; ++j) {
				a[i][j] = in.nextInt();
				assert Math.abs(a[i][j]) <= MAXV;
			}
		}
		
		int[][] c = new int[2][2];
		for (int i = 0; i < 2; ++i) {
			for (int j = 0; j < 2; ++j) {
				c[i][j] = in.nextInt();
				assert Math.abs(c[i][j]) <= 1;				
			}
		}
		assert c[1][1] != 0;
		
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < m; ++j) {				
				for (int ti = Math.max(0, i - 1); ti <= i; ++ti) {
					for (int tj = Math.max(0, j - 1); tj <= j; ++tj) {
						if (ti == i && tj == j) continue;
						a[i][j] -= c[ti - i + 1][tj - j + 1] * a[ti][tj];
					}
				}
				a[i][j] /= c[1][1];
			}
		}
		
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < m; ++j) {
				if (j > 0) {
					out.print(" ");
				}
				out.print(a[i][j]);
			}
			out.println();
		}
	}

	final String FILE_NAME = "cylon";

	SimpleScanner in;
	PrintWriter out;

	@Override
	public void run() {
		try {
			in = new SimpleScanner(new FileReader(FILE_NAME + ".in"));
			out = new PrintWriter(FILE_NAME + ".out");
			solve();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			System.exit(-1);
		}
	}

	public static void main(String[] args) {
		new Thread(new cylon_ab()).start();
	}

	class SimpleScanner extends BufferedReader {

		private StringTokenizer st;
		private boolean eof;

		public SimpleScanner(Reader a) {
			super(a);
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(readLine());
				} catch (Exception e) {
					eof = true;
					return "";
				}
			}
			return st.nextToken();
		}

		boolean seekEof() {
			String s = next();
			if ("".equals(s) && eof)
				return true;
			st = new StringTokenizer(s + " " + st.toString());
			return false;
		}

		private String cnv(String s) {
			if (s.length() == 0)
				return "0";
			return s;
		}

		int nextInt() {
			return Integer.parseInt(cnv(next()));
		}

		double nextDouble() {
			return Double.parseDouble(cnv(next()));
		}

		long nextLong() {
			return Long.parseLong(cnv(next()));
		}
	}
}
