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

public class digits_ft_n2d2 implements Runnable {

	Scanner in;
	PrintWriter out;

	private final static int MAXH = 10;
	private final static int MAXW = 10;
	private final static int MAXK = 100;
	private final static int MAXN = 100;
	private final static int MAXD = 500;

	private void myAssert(boolean e, String message) {
		if (!e) {
			throw new Error("Assertion failure!!! " + message);
		}
	}

	private void myAssert(boolean e) {
		myAssert(e, "");
	}

	class Segment {
		int r1, c1;
		int r2, c2;

		public Segment(int x1, int y1, int x2, int y2) {
			this.r1 = y1;
			this.c1 = x1;
			this.r2 = y2;
			this.c2 = x2;
		}

		public Segment multiply(int k) {
			return new Segment(k * c1, k * r1, k * c2, k * r2);
		}

		public void draw(char[][] f) {
			int dr = (int)Math.signum(r2 - r1);
			int dc = (int)Math.signum(c2 - c1);
			int r = -1;
			int c = -1;
			for (r = r1, c = c1; (r != r2 + dr) || (c != c2 + dc); r += dr, c += dc) {
				f[r][c] = '*';
			} 			
		}

	}

	int[] dr = new int[] {0, 0, 1, -1};
	int[] dc = new int[] {1, -1, 0, 0};

    private void solve() {
		int k = in.nextInt();
		myAssert(1 <= k && k <= MAXK, "k = " + k);
		int d = in.nextInt();
		myAssert(1 <= d && d <= MAXD, "d = " + d);
		int w = in.nextInt();
		myAssert(1 <= w && w <= MAXW, "w = " + w);
		int h = in.nextInt();
		myAssert(1 <= h && h <= MAXW, "h = " + h);
		int n = in.nextInt();
		myAssert(1 <= n && n <= MAXN, "n = " + n);

		Segment[] segs = new Segment[n];
		for (int i = 0; i < n; i++) {
			int x1 = in.nextInt();
			myAssert(0 <= x1 && x1 < w);
            int y1 = in.nextInt();
			myAssert(0 <= y1 && y1 < h);

            int x2 = in.nextInt();
			myAssert(0 <= x1 && x1 < w);
            int y2 = in.nextInt();
			myAssert(0 <= y2 && y2 < h);
			segs[i] = new Segment(x1, y1, x2, y2);
		}
        
		int W = (w - 1) * (k - 1) + w;
		int H = (h - 1) * (k - 1) + h;
		char[][] f = new char[H][W];
		for (char[] c : f) {
			Arrays.fill(c, '.');
		}

		for (Segment s : segs) {
			s.multiply(k).draw(f);
		}

		char[][] f1 = new char[H][W];
        
        d--;

		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				outer:
				for (int dr = -d; dr <= d; dr++) {
					for (int dc = -d + Math.abs(dr); dc <= d - Math.abs(dr); dc++) {
						int nr = i + dr;
						int nc = j + dc;
						if (0 <= nr && nr < H && 0 <= nc && nc < W && f[nr][nc] == '*') {
							f1[i][j] = '*';
							break outer;
						}
					}
				}
			}
		}

		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (f1[i][j] == '*') {
					f[i][j] = '*';
				}
			}
		}

		for (char[] a : f) {
			for (char c : a) {
				out.print(c);
			}
			out.println();
		}

	}

	public void run() {
		try {
			solve();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		} finally {
			out.close();
		}
	}

	public digits_ft_n2d2(String taskName) {
		try {
			in = new Scanner(new File(taskName + ".in"));
			out = new PrintWriter(new File(taskName + ".out"));
		} catch (IOException ioe) {
			ioe.printStackTrace();
			System.exit(1);
		}
	}

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

}