#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; int 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; while (l < r) { a[l]++; l += x; } } 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; }