#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
const int N = 2e5 + 25;
const int M = 3e2 + 32;
int e[N], freq[N];
long long inv[N], npr[N], ans[N];
vector<array<int, 3> > query[N];
long long inverse(long long n) {
  if (n == 1) return 1;
  if (n >= mod) return inverse(n % mod);
  return (mod - mod / n) * inverse(mod % n) % mod;
}
void pre() {
  for (int i = 1; i < N; i++) {
    inv[i] = inverse(i);
  }
}
inline bool cmp(array<int, 3> &a, array<int, 3> &b) {
  int blkl_a = a[0] / M;
  int blkl_b = b[0] / M;
  if (blkl_a != blkl_b) return blkl_a < blkl_b;
  return a[1] < b[1];
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout << setprecision(32);
  pre();
  int n, m, q;
  cin >> n >> m >> q;
  for (int i = 1; i <= n; i++) {
    cin >> e[i];
  }
  for (int i = 1; i <= q; i++) {
    int l, r, k;
    cin >> l >> r >> k;
    query[k].push_back({l, r, i});
  }
  for (int i = 0; i < N; i++) {
    if (query[i].empty()) continue;
    sort(query[i].begin(), query[i].end(), cmp);
    long long cur_prod = 1;
    for (int j = 1; j <= m; j++) {
      freq[j] = i;
    }
    long long tot = i * 1LL * m % mod;
    npr[n] = 1;
    for (int j = 1; j <= n; j++) {
      freq[e[j]]++;
      npr[n - j] = npr[n - j + 1] * (tot + j) % mod;
    }
    int lo = 1, hi = 1;
    for (auto qq : query[i]) {
      int l = qq[0];
      int r = qq[1];
      int ind = qq[2];
      while (lo > l) {
        lo--;
        (cur_prod *= freq[e[lo]]) %= mod;
        freq[e[lo]]--;
      }
      while (hi <= r) {
        (cur_prod *= freq[e[hi]]) %= mod;
        freq[e[hi]]--;
        hi++;
      }
      while (lo < l) {
        freq[e[lo]]++;
        (cur_prod *= inv[freq[e[lo]]]) %= mod;
        lo++;
      }
      while (hi > r + 1) {
        hi--;
        freq[e[hi]]++;
        (cur_prod *= inv[freq[e[hi]]]) %= mod;
      }
      ans[ind] = cur_prod * npr[r - l + 1] % mod;
    }
  }
  for (int i = 1; i <= q; i++) {
    cout << ans[i] << '\n';
  }
  return 0;
}
