#include #include using namespace std; using LL = long long; using P = pair; using Graph = vector>; const int INF = 1 << 29; const long long LINF = 1LL << 60; #define all(x) (x).begin(), (x).end() #define rep(i,n) for(int i = 0; i < (n); ++i) templatevoid chmin(T&a, T b){if(a > b) a = b;} templatevoid chmax(T&a, T b){if(a < b) a = b;} int main(){ int N, Q; cin >> N >> Q; string S; cin >> S; //何文字目までに何が何文字あるかの整理 vector> hyou(N+1, vector(26, 0)); for(int i = 0; i < N; ++i){ for(int j = 0; j < 26; ++j){ hyou[i+1][j] += hyou[i][j]; } hyou[i+1][S[i]-'a']++; } /* cout << endl; for(int i = 0; i < N; ++i){ for(int j = 0; j < 26; ++j){ cout << hyou[i][j] << " "; } cout << endl; } */ //クエリの処理 for(int i = 0; i < Q; ++i){ int L, R, X; cin >> L >> R >> X; vector tmp(26); for(int j = 0; j < 26; ++j){ tmp[j] = hyou[R][j] - hyou[L-1][j]; } for(int j = 0; j < 26; ++j){ X -= tmp[j]; if(X<=0){ cout << char(97+j) << endl; break; } } } }