Sale
In the supermarket "Na troechku", sales are frequently held for products nearing their expiration dates. Each product arrives at the store at a specific time and is removed after a certain period due to its expiration. More precisely, each product has a cost c_i, a delivery time to the store a_i, and a removal time from the store b_i.
Innokentiy has devised several clever plans for visiting the store. Each plan involves choosing a time m_j to visit the store, deciding how long s_j he will spend browsing the aisles, and determining the amount of money k_j he intends to spend. For each plan, he wants to know if it is feasible, meaning whether he can purchase a selection of products with a total cost exactly equal to k_j, with all chosen products being available in the store for the entire duration of his visit.
Help Innokentiy figure out which of his plans can be successfully executed.
Input
The first line of the input contains the number N — the total number of products in the store (1 ≤ N ≤ 500). Following this, each product is described by three integers c_i, a_i, b_i, representing the product's cost, delivery time, and removal time from the store (1 ≤ c_i ≤ 1000, 1 ≤ a_i ≤ b_i ≤ 10^9).
Next, the number M — the number of Innokentiy's plans (1 ≤ M ≤ 500000) is given. Each plan is described by three integers m_j, k_j, s_j, indicating the time of Innokentiy's arrival at the store, the amount of money he plans to spend, and the duration of his stay (1 ≤ m_j ≤ 10^9, 1 ≤ k_j ≤ 100000, 0 ≤ s_j ≤ 10^9).
Note that these are merely plans, meaning the store's situation remains unchanged regardless of whether Innokentiy can execute the plan.
Output
For each plan, output "YES" on a separate line if Innokentiy can carry it out, and "NO" otherwise.