The input consists of several test cases.
The first line of each test case contains four integer numbers XN, YN, XT, and YT, separated by single spaces. They are, correspondingly, width and height of the niche, and width and height of the old tome in inches (1 ≤ XN, YN, XT, YT ≤ 1000).
The second line contains a single integer number N (1 ≤ N ≤ 100) that represents the number of the shelves. Then N lines follow. Each line represents a single shelf along with its two supporting pegs, and contains five integer numbers yi, xi, li, x1i, x2i, separated by spaces, where:
yi (0 < yi < YN) - the height of the ith shelf above the bottom of the niche in inches.
xi (0 ≤ xi < XN) - the distance between the left end of the ith shelf and the left edge of the niche in inches.
li (0 < li ≤ XN - xi) - the length of the ith shelf in inches.
x1i (0 ≤ x1i ≤ li/2) - the distance between the left end of the ith shelf and its leftmost supporting peg in inches.
x2i (li/2 ≤ x2i ≤ li; x1i < x2i) - the distance between the left end of the ith shelf and its rightmost supporting peg in inches.
All shelves are situated on different heights and are properly supported by their pegs. The problem is guaranteed to have a solution for the input data.