// Arup Guha
// 1/31/2015
// Solution to 2015 MCPC Problem I: Wet Tiles

import java.util.*;

public class i {

	// How the leak travels.
	final public static int[] DX = {-1,0,0,1};
	final public static int[] DY = {0,-1,1,0};

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int len = stdin.nextInt();

		// Process each case.
		while (len != -1) {

			// Read in the rest of this case.
			int wid = stdin.nextInt();
			int maxT = stdin.nextInt();
			int numLeaks = stdin.nextInt();
			int numWalls = stdin.nextInt();
			ArrayList<Integer> start = new ArrayList<Integer>();

			// Fill in initial leaks.
			int[][] grid = new int[len][wid];
			for (int i=0; i<numLeaks; i++) {
				int x = stdin.nextInt() - 1;
				int y = stdin.nextInt() - 1;
				grid[x][y] = 1;
				start.add(x*wid+y);
			}

			// Fill in walls.
			for (int i=0; i<numWalls; i++) {

				// Read in the wall and set deltas.
				int sx = stdin.nextInt() - 1;
				int sy = stdin.nextInt() - 1;
				int ex = stdin.nextInt() - 1;
				int ey = stdin.nextInt() - 1;
				int dx = (sx != ex) ? (ex-sx)/Math.abs(ex-sx) : 0;
				int dy = (sy != ey) ? (ey-sy)/Math.abs(ey-sy) : 0;

				// Set up walls.
				while (sx != ex || sy != ey){
					grid[sx][sy] = -1;
					sx += dx;
					sy += dy;
				}
				grid[ex][ey] = -1;
			}

			// Solve it!
			System.out.println(floodfill(grid, start, maxT));

			// Get length for next case.
			len = stdin.nextInt();
		}
	}

	// Run the floodfill and determint the number of affected squares.
	public static int floodfill(int[][] grid, ArrayList<Integer> start, int maxT) {

		int len = grid.length;
		int wid = grid[0].length;

		// Set up queue for bfs.
		LinkedList<Integer> q = new LinkedList<Integer>();
		for (int i=0; i<start.size(); i++)
			q.offer(start.get(i));

		// Our counter.
		int wet = 0;

		// For now we'll set up a regular BFS.
		while (q.size() > 0) {

			// Get next item.
			int next = q.poll();
			int x = next/wid;
			int y = next%wid;

			// We're done.
			if (grid[x][y] > maxT) break;

			// Count this square.
			wet++;

			// Enqueue dry neighbors that aren't walls, setting distance.
			for (int i=0; i<DX.length; i++) {
				if (inbounds(x+DX[i], y+DY[i], len, wid) && grid[x+DX[i]][y+DY[i]] == 0) {
					q.offer((x+DX[i])*wid+y+DY[i]);
					grid[x+DX[i]][y+DY[i]] = grid[x][y] + 1;
				}
			}
		}

		// This is our answer.
		return wet;
	}

	public static boolean inbounds(int x, int y, int len, int wid) {
		return x >= 0 && x < len && y >= 0 && y < wid;
	}
}