There will be multiple input sets. For each input set, the first line will contain two integers, N and M , ( 0 < N, M <=100000 ), separated by a space. N is the number of trees, and M is the number of paths.
The next N lines each contain two space-separated integers, X and Y , specifying the coordinates of a tree. X and Y may be any 32-bit integers.
The next M lines each describe a path (a vertical or horizontal line). They have the form x = K or y = K , with no spaces. K may be any 32-bit integer. x and y will be lower case.
End of the input is signified by a line with two space-separated 0's.