N,Q=gets.chomp.split(" ").map(&:to_i)
s_ary=gets.chomp.to_s.split('')
ary = Array.new(N, 1)
hash=Hash.new {|h,k| h[k] = {n: [], r:[]}}
s_ary.each_with_index do |s, i|
  hash[s][:n] << i
  hash[s][:r].unshift(i)
end