#![allow(unused_macros)] #![allow(dead_code)] #![allow(unused_imports)] // # ファイル構成 // - use 宣言 // - lib モジュール // - main 関数 // - basic モジュール // // 常に使うテンプレートライブラリは basic モジュール内にあります。 // 問題に応じて使うライブラリ lib モジュール内にコピペしています。 // ライブラリのコードはこちら → https://github.com/RheoTommy/at_coder // Twitter はこちら → https://twitter.com/RheoTommy use std::collections::*; use std::io::{stdout, BufWriter, Write}; use crate::basic::*; use crate::lib::*; pub mod lib {} fn main() { let mut io = IO::new(); let _n = io.next_usize(); let q = io.next_usize(); let s = io.next_chars().collect::>(); 'query: for _ in 0..q { let l = io.next_usize() - 1; let r = io.next_usize(); let mut x = io.next_int(); let mut v = vec![0; 26]; for i in l..r { v[(s[i] as u8 - b'a') as usize] += 1; } for i in 0..26 { x -= v[i]; if x <= 0 { io.println((i as u8 + b'a') as char); continue 'query; } } } } pub mod basic { pub const U_INF: u64 = (1 << 60) + (1 << 30); pub const I_INF: i64 = (1 << 60) + (1 << 30); pub struct IO { iter: std::str::SplitAsciiWhitespace<'static>, buf: std::io::BufWriter>, } impl IO { pub fn new() -> Self { use std::io::*; let mut input = String::new(); std::io::stdin().read_to_string(&mut input).unwrap(); let input = Box::leak(input.into_boxed_str()); let out = Box::new(stdout()); IO { iter: input.split_ascii_whitespace(), buf: BufWriter::new(Box::leak(out).lock()), } } pub fn next_str(&mut self) -> &str { self.iter.next().unwrap() } pub fn next(&mut self) -> T where ::Err: std::fmt::Debug, { self.iter.next().unwrap().parse().unwrap() } pub fn next_usize(&mut self) -> usize { self.next() } pub fn next_uint(&mut self) -> u64 { self.next() } pub fn next_int(&mut self) -> i64 { self.next() } pub fn next_float(&mut self) -> f64 { self.next() } pub fn next_chars(&mut self) -> std::str::Chars { self.next_str().chars() } pub fn next_vec(&mut self, n: usize) -> Vec where ::Err: std::fmt::Debug, { (0..n).map(|_| self.next()).collect::>() } pub fn print(&mut self, t: T) { use std::io::Write; write!(self.buf, "{}", t).unwrap(); } pub fn println(&mut self, t: T) { self.print(t); self.print("\n"); } pub fn print_iter>( &mut self, mut iter: I, sep: &str, ) { if let Some(v) = iter.next() { self.print(v); for vi in iter { self.print(sep); self.print(vi); } } self.print("\n"); } pub fn flush(&mut self) { use std::io::Write; self.buf.flush().unwrap(); } } }