I have bought some greeting cards for my friends but in order to send them I must also buy some envelopes. Each card must be put inside a separate envelope without bending or tearing. The envelopes are made of so thin papers that one can put inside an envelope a card having even the same dimensions as that envelope. Please help me choose envelopes so that the total amount I need to spend in buying them is minimized. Input The input may contain multiple test cases. ThefirstlineofeachtestcasecontainstwointegersM (1≤M ≤5)andN (M ≤N ≤10)whereM is the number of greeting cards and N is the number of envelopes to choose from. The ith (1 ≤ i ≤ M) of the next M lines consists of two integers li and wi (1 ≤ li,wi ≤ 50000) giving the dimensions of the ith greeting card. The ith (1 ≤ i ≤ N) of the next N lines contains three integers Li, Wi and Ci (1 ≤ Li, Wi, Ci ≤ 50000) where Li and Wi give the dimensions of the ith envelope and Ci is its price in Taka. The input terminates with two zeros for M and N. Output For each test case in the input first print the test case number on a separate line as shown in the sample output. If an envelope can be chosen for each of the greeting cards in the input, print one line for each where the ith line contains the number of the envelope (in the order given in the input) inside which the ith greeting card should be put. Otherwise, print “cannot buy” on a line by itself. Note that if there are multiple solutions with minimum cost, any one of them is acceptable. Print a blank line between two successive test cases. Sample Input 24 105 9 99 149 110 10 10 100 50 5 150 100 7 90 140 15 12 100 150 99 149 10 142 100 5 00 Sample Output Case #1 2 3

2/2 Case #2 cannot buy