class SegmentTree
	def initialize(arr, l = 0, r = arr.size - 1)
		@l = l
		@r = r
		if l == r
			@val = arr[l]
			@leftmost_min = [l, @val]
			@sum = arr[l]
			@sum_rightmost_min = [r, @val]
		else
			c = (l + r) / 2
			@left_child = self.class.new(arr, l, c)
			@right_child = self.class.new(arr, c+1, r)
			@sum = @left_child.sum + @right_child.sum

			lx, lv = @left_child.leftmost_min
			rx, rv = @right_child.leftmost_min
			@leftmost_min = ( rv < lv ? [rx, rv] : [lx, lv] )

			lx, lv = @left_child.sum_rightmost_min
			rx, rv = @right_child.sum_rightmost_min
			rv += @left_child.sum
			@sum_rightmost_min = ( rv <= lv ? [rx, rv] : [lx, lv] )
		end
	end

	def sum(l = @l, r = @r)
		if l == @l && r == @r
			@sum
		elsif r <= @left_child.r
			@left_child.sum(l, r)
		elsif @right_child.l <= l
			@right_child.sum(l, r)
		else
			ls = @left_child.sum(l, @left_child.r)
			rs = @right_child.sum(@right_child.l, r)
			ls + rs
		end
	end

	def sum_rightmost_min(l = @l, r = @r)
		if l == @l && r == @r
			@sum_rightmost_min
		elsif r <= @left_child.r
			@left_child.sum_rightmost_min(l, r)
		elsif @right_child.l <= l
			@right_child.sum_rightmost_min(l, r)
		else
			lx, lv = @left_child.sum_rightmost_min(l, @left_child.r)
			rx, rv = @right_child.sum_rightmost_min(@right_child.l, r)
			rv += @left_child.sum(l, @left_child.r)
			(rv <= lv) ? [rx, rv] : [lx, lv]
		end
	end

	def leftmost_min(l = @l, r = @r)
		return @leftmost_min if l == @l && r == @r
		if r <= @left_child.r
			@left_child.leftmost_min(l, r)
		elsif @right_child.l <= l
			@right_child.leftmost_min(l, r)
		else
			lx, lv = @left_child.leftmost_min(l, @left_child.r)
			rx, rv = @right_child.leftmost_min(@right_child.l, r)
			rv < lv ? [rx, rv] : [lx, lv]
		end
	end

	def update(i, x)
		if @l == i && @l == @r
			@val = x
			@leftmost_min[1] = x
			@sum = x
			@sum_rightmost_min = [r, @val]
			return
		end
		if i <= @left_child.r
			@left_child.update(i, x)
		elsif @right_child.l <= i
			@right_child.update(i, x)
		else
			raise
		end
		lx, lv = @left_child.leftmost_min
		rx, rv = @right_child.leftmost_min
		@leftmost_min = (rv < lv ? [rx, rv] : [lx, lv])

		@sum = @left_child.sum + @right_child.sum

		lx, lv = @left_child.sum_rightmost_min
		rx, rv = @right_child.sum_rightmost_min
		rv += @left_child.sum
		@left_child.sum
		@sum_rightmost_min = ( rv < lv ? [rx, rv] : [lx, lv] )
	end

	attr_reader :val, :l, :r
end

class Array
	def accum
		ac = Array.new(size + 1)
		ac[0] = 0
		(1..size).each do |i|
			ac[i] = ac[i-1] + self[i-1]
		end
		ac
	end
end

n, q = gets.split.map(&:to_i)
par = gets.chomp.split("").map {|c| 1 - 2 * (c.ord - 40)}

t = SegmentTree.new(par)

q.times do
	i = gets.to_i - 1
	j = nil
	if par[i] == +1
		j, _ = t.leftmost_min
		j = i if j > i
	else
		j, x = t.sum_rightmost_min(0, i)
		if x > 0
			j = 1
		end
	end
	p j + 1
	par[i] *= -1
	par[j] *= -1
	t.update(i, par[i])
	t.update(j, par[j])
end