import java.io.*; import java.util.*; public class colorflip { Scanner in = new Scanner(System.in); boolean WHITE = true; boolean BLACK = false; double h; double v; double x; double y; public static void main(String[] args) { new colorflip().solve(); } public void solve() { //in = new Scanner("81 32 0.333333333333 0.5\n6\n16 30\n16 25\n16 12.0001\n16 11.9999\n16 7.987654321\n16 7.0123456789\n10 10 0.123456789 0.987654321\n2\n0.432 0.9876\n9.432 0.9876\n0 0 0 0"); // for each case int curr_case = 1; while(true) { // read dimensions String[] temp; try { temp = in.nextLine().split(" "); if(temp[0].equals("0")) break; double x_max = Double.parseDouble(temp[0]); double y_max = Double.parseDouble(temp[1]); h = Double.parseDouble(temp[2]); v = Double.parseDouble(temp[3]); int num_points = Integer.parseInt(in.nextLine()); System.out.println("Case " + curr_case + ":"); for(int i=0; i y_div) { return color; } else return check(x_div,x_max,y_min,y_div,!color); } }