#include <bits/stdc++.h>
using namespace std;
const int maxn = 310000;
const int maxr = 300010;
const long long mod = 998244353;
struct item {
  long long x, y, id, ans;
} a[maxn];
bool cmp(item a, item b) { return a.y < b.y; }
bool recmp(item a, item b) { return a.id < b.id; }
long long s1 = 0, s2 = 0;
long long n, m, dv = 1, now = 0;
long long d[maxn] = {};
long long fact[maxn] = {};
long long invfact[maxn] = {};
long long powmod(long long a, long long b, long long p) {
  long long ans = 1;
  for (; b; b >>= 1) {
    if (b & 1) ans = (long long)(ans * a) % p;
    a = (long long)(a * a) % p;
  }
  return ans % p;
}
long long invx(long long x) { return powmod(x, mod - 2, mod); }
long long inv(long long x) { return (fact[x - 1] * invfact[x]) % mod; }
long long prem(long long n, long long m) {
  return (fact[n] * invfact[n - m]) % mod;
}
long long comb(long long n, long long m) {
  return ((fact[n] * invfact[n - m]) % mod * invfact[m]) % mod;
}
int main() {
  fact[0] = fact[1] = invfact[0] = invfact[1] = 1;
  for (long long i = 1; i <= maxr; i++) fact[i] = (fact[i - 1] * i) % mod;
  invfact[maxr] = invx(fact[maxr]);
  for (long long i = maxr - 1; i >= 2; i--)
    invfact[i] = (invfact[i + 1] * (i + 1)) % mod;
  scanf("%lld%lld", &n, &m);
  for (long long i = 1; i <= n; i++) scanf("%lld", &d[i]);
  sort(d + 1, d + 1 + n);
  for (long long i = 1; i <= n; i++) s1 = (s1 + d[i]) % mod;
  for (long long i = 1; i <= m; i++)
    scanf("%lld%lld", &a[i].x, &a[i].y), a[i].id = i;
  sort(a + 1, a + 1 + m, cmp);
  dv = invfact[n];
  for (long long i = 1; i <= m; i++) {
    while (d[now + 1] < a[i].y) now++, s2 = (s2 + d[now]) % mod;
    long long ans = 0;
    if (a[i].x <= n - now)
      ans =
          (ans + ((((comb(n, now - 1) * fact[now - 1]) % mod * fact[n - now]) %
                   mod * ((n - now - a[i].x + 1) % mod + mod) % mod) %
                  mod * s2) %
                     mod) %
          mod;
    if (a[i].x < n - now)
      ans = (ans + (((((comb(n, now) * comb(n - now - 1, a[i].x)) % mod *
                       fact[a[i].x]) %
                      mod * fact[n - now - a[i].x]) %
                     mod * fact[now]) %
                    mod * ((s1 - s2 + mod) % mod)) %
                       mod) %
            mod;
    a[i].ans = (ans * invfact[n]) % mod;
  }
  sort(a + 1, a + 1 + m, recmp);
  for (long long i = 1; i <= m; i++) printf("%lld\n", a[i].ans);
  return 0;
}
