class SegmentTree
  def initialize(arr, l = 0, r = arr.size - 1)
    @l = l
    @r = r
    if @l == @r
      @leftmost_close = (arr[l] == ?) ? l : Float::INFINITY)
    else
      c = (l + r) / 2
      @left_child = self.class.new(arr, l, c)
      @right_child = self.class.new(arr, c + 1, r)
      @leftmost_close = [@left_child.leftmost_close, @right_child.leftmost_close].min
    end
  end

  attr_reader :leftmost_close, :l, :r

  def flip(i)
    if @l == @r
      @leftmost_close = (@leftmost_close == Float::INFINITY ? l : Float::INFINITY)
    else
      (i <= @left_child.r ? @left_child : @right_child).flip(i)
      @leftmost_close = [@left_child.leftmost_close, @right_child.leftmost_close].min
    end
  end
end

class LazySegmentTree
  def initialize(arr, l = 0, r = arr.size - 1)
    @l, @r = l, r
    @lazy = nil
    if @l == @r
      @min = arr[l]
    else
      c = (l + r) / 2
      @left_child = self.class.new(arr, l, c)
      @right_child = self.class.new(arr, c + 1, r)
      @min = [@left_child.min, @right_child.min].min
    end
  end

  attr_reader :min, :l, :r, :left_child, :right_child, :lazy

  def add(l, x)
    if @l == @r
      @min += x
    elsif l == @l
      if @lazy
        @lazy += x
      else
        @lazy = x
      end
    else
      force
      if l <= @left_child.r
        @left_child.add(l, x)
        @right_child.add(@right_child.l, x)
      else
        @right_child.add(l, x)
      end
      @left_child.force
      @right_child.force
      @min = [@left_child.min, @right_child.min].min
    end
  end

  def force
    return if !@lazy
    x = @lazy
    @lazy = nil
    @min += x
    @left_child.add(@left_child.l, x)
    @right_child.add(@right_child.l, x)
  end

  def rightmost_zero_pos(r)
    force
    return -1 if @min > 0
    return @l if @l == @r
    return @left_child.rightmost_zero_pos(r) if r <= @left_child.r
    ret = @right_child.rightmost_zero_pos(r)
    return @left_child.rightmost_zero_pos(@left_child.r) if ret == -1
    ret
  end

  def rightmost_one_pos(r)
    force
    return -1 if @min > 1
    return @min == 1 ? @l : -1 if @l == @r
    return @left_child.rightmost_one_pos(r) if r <= @left_child.r
    ret = @right_child.rightmost_one_pos(r)
    return @left_child.rightmost_one_pos(@left_child.r) if ret == -1
    ret
  end
end

n, q = gets.split.map(&:to_i)
a = gets.chomp.split("")
b = [0]
a.each do |c|
  if c == ?(
    b << b[-1] + 1
  else
    b << b[-1] - 1
  end
end
b.shift

seg1 = SegmentTree.new(a)
seg2 = LazySegmentTree.new(b)
q.times do
  i = gets.to_i - 1
  if a[i] == ?(
    a[i] = ?)
    seg1.flip(i)
    seg2.add(i, -2)
    j = seg1.leftmost_close
    puts j + 1
    seg1.flip(j)
    seg2.add(j, 2)
    a[j] = ?(
  else # a[i] == ?)
    a[i] = ?(
    seg1.flip(i)
    seg2.add(i, 2)
    zero = seg2.rightmost_zero_pos(i)
    j = nil
    if zero == -1
      j = seg2.rightmost_one_pos(i) + 1
    else
      one = seg2.rightmost_one_pos(i)
      if zero + 1 < one
        j = one + 1
      else
        j = zero + 2
      end
    end
    puts j + 1
    seg1.flip(j)
    seg2.add(j, -2)
    a[j] = ?)
  end
end
