#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1000001;
const long long mod = 998244353;
long long numInv[MAXN + 10], facInv[MAXN + 10], fac[MAXN + 10];
void pre() {
  numInv[0] = numInv[1] = 1;
  for (int i = 2; i <= MAXN; i++)
    numInv[i] = numInv[mod % i] * (mod - mod / i) % mod;
  facInv[0] = facInv[1] = 1;
  for (int i = 2; i <= MAXN; i++) facInv[i] = (numInv[i] * facInv[i - 1]) % mod;
  fac[0] = 1;
  for (int i = 1; i <= MAXN; i++) fac[i] = (fac[i - 1] * i) % mod;
}
long long nCr(long long n, long long r) {
  if (r < 0) return 0;
  return ((fac[n] * facInv[r]) % mod * facInv[n - r]) % mod;
}
long long mul(vector<long long> a) {
  long long ans = a[0];
  for (int i = 1; i < (int)a.size(); i++) {
    ans = (ans * (a[i] % mod)) % mod;
    if (ans < 0) ans += mod;
  }
  if (ans < 0) ans += mod;
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  pre();
  int n, m;
  cin >> n >> m;
  vector<long long> nums(n), suf;
  for (int i = 0; i < (int)n; i++) cin >> nums[i];
  sort(nums.begin(), nums.end());
  suf = nums;
  for (int i = n - 2; i >= 0; i--) suf[i] += suf[i + 1];
  for (int i = 0; i < (int)m; i++) {
    long long a, b;
    cin >> b >> a;
    int idx = lower_bound(nums.begin(), nums.end(), a) - nums.begin();
    int k = n - idx;
    if (idx == n or b > k) {
      cout << 0 << '\n';
      continue;
    }
    long long ans = mul({fac[b], fac[k - b], facInv[k], fac[n], suf[idx],
                         nCr(k - 1, k - b - 1)}) +
                    mul({nCr(k, b), k - b + 1, fac[b], fac[k - b],
                         facInv[k + 1], fac[n], suf[0] - suf[idx]});
    if (ans >= mod) ans -= mod;
    cout << (ans * facInv[n]) % mod << '\n';
  }
  return 0;
}
