const SIZE: usize = 26; fn main() { let mut nq = String::new(); std::io::stdin().read_line(&mut nq).ok(); let nq: Vec = nq.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); let n = nq[0]; let q = nq[1]; let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); let s = s.trim().chars().map(|c| c as usize - 'a' as usize).collect::>(); let queries = (0..q).map(|_| { let mut temp = String::new(); std::io::stdin().read_line(&mut temp).ok(); let temp: Vec = temp.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); (temp[0]-1, temp[1], temp[2]) }) .collect::>(); let alphabets = "abcdefghijklmnopqrstuvwxyz".chars().collect::>(); let mut dp = vec![vec![0usize; SIZE]; n+1]; for i in 0..n { dp[i+1][s[i]] += 1; for j in 0..SIZE { dp[i+1][j] += dp[i][j]; } } for &(l, r, x) in queries.iter() { let mut diffs = vec![0usize; SIZE]; for i in 0..SIZE { diffs[i] = dp[r][i] - dp[l][i]; } let mut summary = 0usize; for i in 0..SIZE { summary += diffs[i]; if summary >= x { println!("{}", alphabets[i]); break; } } } }