#include #include #define rep(i, n) for (int i = 0; i < n; i++) #define ALL(a) a.begin(), a.end() #define ll int #define pii pair #define pil pair #define pli pair #define vc vector using namespace std; constexpr int inf = 1e5 + 1, s_inf = 316; int pl[s_inf][inf], a[inf]; void solve() { int n, m; cin >> n >> m; rep(k, n) { int l, r, x, y; cin >> l >> r >> x >> y; l = (l - y + x - 1) / x * x + y; r = (r - y + x) / x * x + y; if (x < s_inf) { pl[x][l]++; if (r < inf) pl[x][r]--; } else { while (l < r) { a[l]++; l += x; } } } for (int x = 1; x < s_inf; x++) { for (int y = x; y < inf; y++) pl[x][y] += pl[x][y - x]; for (int y = 0; y < inf; y++) a[y] += pl[x][y]; } for (int i = 0, x; i < m; i++) { cin >> x; cout << a[x] << '\n'; } } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(13); solve(); return 0; }