The first line of the standard input contains an integer $n (1 ≤ n ≤ 2000)$, the number of computers that are available at the shop. Each of next $n$ lines contains a description of one computer. It consists of three space-separated integers $c_i$, $f_i$, and $v_i (1 ≤ c_i ≤ 50, 1 ≤ f_i ≤ 10^9, 1 ≤ v_i ≤ 10^9)$ which represent the number of cores, the clock rate, and the price, respectively.
The next line contains an integer $m (1 ≤ m ≤ 2000)$, the number of orders. Each of next $m$ lines contains a description of one order. It consists of three space-separated integers $C_j$, $F_j$, and $V_j (1 ≤ C_j ≤ 50, 1 ≤ F_j ≤ 10^9, 1 ≤ V_j ≤ 10^9)$ which represent the number of cores needed, the minimum allowed clock rate, and the customer’s budget, respectively.
