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

public class digits_md implements Runnable {

	private Scanner in;
	private PrintWriter out;

	public void run() {
		try {
			solve();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	private void solve() throws IOException {
		in = new Scanner(new File("digits.in"));
		out = new PrintWriter("digits.out");
		int k = in.nextInt();
		int d = in.nextInt() - 1;
		int w = in.nextInt();
		int h = in.nextInt();
		int n = in.nextInt();
		W = (w - 1) * k;
		H = (h - 1) * k;
		b = new boolean[W + 1][H + 1];
		a = new int[2 * W + 1][H + d + 1];
		for (int i = 0; i < n; i++) {
			int x1 = in.nextInt() * k;
			int y1 = in.nextInt() * k;
			int x2 = in.nextInt() * k;
			int y2 = in.nextInt() * k;
			int dx = (int) Math.signum(x2 - x1);
			int dy = (int) Math.signum(y2 - y1);
			while (x1 != x2 || y1 != y2) {
				b[x1][y1] = true;
				x1 += dx;
				y1 += dy;
			}
			b[x1][y1] = true;
		}
		for (int j = 0; j <= H + d; j++) {
			for (int i = 0; i <= 2 * W; i++) {
				a[i][j] = a(i - 2, j - 1) + a(i + 2, j - 1) - a(i, j - 2);
				if (i % 2 == 0) {
					if (j > 0 && j - 1 <= H && b[i / 2][j - 1])
						a[i][j]++;
					if (j <= H && b[i / 2][j])
						a[i][j]++;
				} else {
					if (j > 0 && j - 1 <= H) {
						if (b[i / 2][j - 1])
							a[i][j]++;
						if (b[i / 2 + 1][j - 1])
							a[i][j]++;
					}
				}
			}
		}
		for (int j = 0; j <= H; j++) {
			for (int i = 0; i <= 2 * W; i += 2) {
				int c = a(i, j + d) - a(i + 2 * d + 1, j) - a(i - 2 * d - 1, j) + a(i, j - d - 1);
				if (c > 0)
					out.print('*');
				else
					out.print('.');
			}
			out.println();
		}
		in.close();
		out.close();
	}
	
	int[][] a;
	boolean[][] b;
	int W, H;

	private int a(int i, int j) {
		if (i < 0) {
			int s = (1 - i) / 2;
			i += 2 * s;
			j -= s;
			if (j < 0)
				return 0;
			return (i <= 2 * W ? a[i][j] : 0) + ((i == 1 && j <= H && b[0][j]) ? 1 : 0);
		}
		if (i > 2 * W) {
			int s = (i - 2 * W + 1) / 2;
			i -= 2 * s;
			j -= s;
			if (j < 0)
				return 0;
			return (i >= 0 ? a[i][j] : 0) + ((i == 2 * W - 1 && j <= H && b[W][j]) ? 1 : 0);
		}
		if (j < 0)
			return 0;
		return a[i][j];
	}

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

}
