/** * @FileName a.cpp * @Author kanpurin * @Created 2021.04.11 15:40:15 **/ #include "bits/stdc++.h" using namespace std; typedef long long ll; int main() { int n,q;cin >> n >> q; string s;cin >> s; vector l(q),r(q),x(q),idx(q),cnt(26,0); vector ans(q); int sq = sqrt(q),now_l = 0, now_r = 0; for (int i = 0; i < q; i++) { cin >> l[i] >> r[i] >> x[i]; l[i]--; } iota(idx.begin(), idx.end(),0); sort(idx.begin(), idx.end(), [&](int a,int b) { if (l[a]/sq != l[b]/sq) return l[a] < l[b]; if (l[a]/sq % 2 == 1) return r[a] > r[b]; return r[a] < r[b]; }); for (int i = 0; i < q; i++) { while(now_l > l[idx[i]]) cnt[s[--now_l]-'a']++; while(now_r < r[idx[i]]) cnt[s[now_r++]-'a']++; while(now_l < l[idx[i]]) cnt[s[now_l++]-'a']--; while(now_r > r[idx[i]]) cnt[s[--now_r]-'a']--; int sum = 0; for (int j = 0; j < 26; j++) { sum += cnt[j]; if (sum >= x[idx[i]]) { ans[idx[i]] = 'a'+j; break; } } } for (int i = 0; i < q; i++) cout << ans[i] << endl; return 0; }