Guessing Game

No attempts yetTime limit2sMemory limit512 MB

Problem

Jaehyun has two integer lists a1,,aNa_1, \dots, a_N and b1,,bMb_1, \dots, b_M. Jeffrey wants to know these numbers, but Jaehyun won't reveal them directly. So Jeffrey asks a series of questions of the form "How big is ai+bja_i + b_j?" Even then Jaehyun refuses to give the exact value; he answers only "It's at least cc" (meaning ai+bjca_i + b_j \ge c) or "It's at most cc" (meaning ai+bjca_i + b_j \le c). After collecting every answer, Jeffrey still cannot reconstruct any consistent numbers no matter how hard he tries, and starts to suspect that Jaehyun lied on some of the answers. Given Jaehyun's answers, determine whether integer lists consistent with all of them exist, or whether it can be proven that Jaehyun definitely lied.

Input

The input contains multiple test cases. Each test case begins with a line of three positive integers NN, MM, and QQ — the lengths of Jaehyun's two lists and the number of questions Jeffrey asked — satisfying 2N+M10002 \le N + M \le 1000 and 1Q100001 \le Q \le 10000. Each of the next QQ lines has the form i j <= c or i j >= c: the former means ai+bjca_i + b_j \le c and the latter means ai+bjca_i + b_j \ge c, where 1000c1000-1000 \le c \le 1000. The input ends with a line 0 0 0, which is not processed.

Output

For each test case, print a single line: Possible if there exist integers a1,,aNa_1, \dots, a_N and b1,,bMb_1, \dots, b_M consistent with all of Jaehyun's answers, or Impossible if the answers can be proven contradictory (that is, Jaehyun definitely lied).