#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2e6 + 5, mod = 998244353;
struct node {
int l, r;
}a[N];
int n, q, x, sum[N * 2], c[N * 2], p[N * 2], m, cnt[N * 2], ans[N * 2], sum1, ans1;
vector<int> v[N * 2];
int val(int x) {
return x * x % mod;
}
int mypow(int a, int b) {
int tmp = 1;
while (b) {
if (b & 1) {
tmp = tmp * a % mod;
}
a = a * a % mod;
b >>= 1;
}
return tmp;
}
void Solve() {
cin >> x;
int u = x, k = mypow(n, mod - 2) * x % mod;
int res = ans1 % mod;
x -= sum1;
int l = 1, r = m + 1;
while (l < r) {
int mid = (l + r + 1) >> 1;
if (sum[mid] <= x) {
l = mid;
}
else r = mid - 1;
}
x -= sum[l], res = (res + ans[l]) % mod;
res = (res + k * k % mod * n % mod) % mod;
res = ((res - 2 * u % mod * k % mod) % mod + mod) % mod;
if (!x) {
cout << res * mypow(n, mod - 2) % mod << "\n";
return ;
}
int tmp1 = x / cnt[l], tmp2 = x % cnt[l];
res = (res + cnt[l] * (val(tmp1 + p[l]) - val(p[l]) + mod) % mod + tmp2 * (val(tmp1 + p[l] + 1ll) - val(p[l] + tmp1) + mod) % mod) % mod;
cout << res * mypow(n, mod - 2) % mod << "\n";
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> q;
for (int i = 1; i <= n; i++) {
cin >> a[i].l >> a[i].r;
sum1 += a[i].l;
ans1 += (a[i].l) * (a[i].l) % mod;
ans1 %= mod;
c[i] = a[i].l, c[i + n] = a[i].r;
}
sort(c + 1, c + 2 * n + 1);
for (int i = 1; i <= 2 * n; i++) {
if (c[i] != c[i - 1]) {
p[++m] = c[i];
}
}
for (int i = 1; i <= n; i++) {
a[i].l = lower_bound(p + 1, p + m + 1, a[i].l) - p;
a[i].r = lower_bound(p + 1, p + m + 1, a[i].r) - p;
v[a[i].l].push_back(1);
v[a[i].r].push_back(-1);
}
for (int i = 1; i <= m; i++) {
cnt[i] = cnt[i - 1];
for (auto cur : v[i]) {
if (cur == 1) {
cnt[i]++;
}
}
sum[i] = sum[i - 1] + cnt[i - 1] * (p[i] - p[i - 1]);
ans[i] = (ans[i - 1] + cnt[i - 1] * ((p[i] * p[i]) % mod - (p[i - 1] * p[i - 1]) % mod) % mod) % mod;
for (auto cur : v[i]) {
if (cur == -1) {
cnt[i]--;
}
}
}
sum[m + 1] = 1e18, cnt[m + 1] = cnt[m];
while(q--) {
Solve();
}
return 0;
}