// #define _GLIBCXX_DEBUG #include using namespace std; #include using namespace atcoder; using ll = long long; #define rep(i,n) for (ll i = 0; i < (n); ++i) using vl = vector; using vvl = vector; using P = pair; #define pb push_back #define int long long #define double long double #define INF (ll) 3e18 // Ctrl + Shift + B コンパイル // Ctrl + C 中断 // ./m 実行 signed main(){ int n, m; cin >> n >> m; map> xy_lr; rep(i,n){ int l, r, x, y; cin >> l >> r >> x >> y; xy_lr[P(x,y)].emplace_back(l,r); } vl v(100010); for(auto [xy, vlr] : xy_lr){ auto[x, y] = xy; multiset ls; multiset rs; for(auto [l, r] : vlr) {ls.insert(l); rs.insert(r);} ls.insert(INF); rs.insert(INF); int count = 0; for(int i = y; i <= 100000; i += x){ while(*ls.begin() <= i){ count++; ls.erase(ls.begin()); } while(*rs.begin() < i){ count--; rs.erase(rs.begin()); } v[i] += count; } } vl a(m); rep(i,m) cin >> a[i]; for(auto x : a){ cout << v[x] << endl; } }