#define DEBUG 0
#define MAX_N 1000  // relvad
#define MAX_K 20  // taringud
#define MAX_R 100  // tahud
#define ll long long
#include <iostream>
using namespace std;

ll pow(int x, int p) {
	if (p == 0) return 1;
	if (p == 1) return x;

	ll tmp = pow(x, p / 2);
	if (p % 2 == 0) return tmp * tmp;
	else return x * tmp * tmp;
}

int k[MAX_N], r[MAX_N], f[MAX_N];
int t;

ll count(int j, int sum, int lev) {
	ll res = 0;
	for (int i = 1; i <= r[j]; i++) {
		int sum2 = sum + i;
		if (lev == k[j]) {
			if (sum2 + f[j] >= t)
				res++;
		}
		else {
			res += count(j, sum2, lev + 1);
		}
	}

	return res;
}

ll getprob(int j) {
	return count(j, 0, 1);
}

int main() {
	int n, q;
	cin >> n >> q;
	for (int i = 0; i < n; i++) {
		cin >> k[i] >> r[i] >> f[i];
	}

	for (int i = 0; i < q; i++) {
		cin >> t;
		int bestn = -1;
		ll bestnum = 0, bestden = 1000000;
		for (int j = 0; j < n; j++) {
			ll p = getprob(j);
			ll c = pow(r[j], k[j]);

#if DEBUG
			cout << j + 1;
			cout << " " << p << " / " << c << " = " << (double)p / c << endl;
#endif // DEBUG

			if (p * bestden > c * bestnum) {
				bestden = c;
				bestnum = p;
				bestn = j;
			}
		}
		cout << bestn + 1 << endl;
#if DEBUG
		cout << " " << " " << bestnum << " / " << bestden << endl;
#endif // DEBUG
	}

	return 0;
}
