#include<iostream>
#include<vector>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
#define MX 300005
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define root 1,n,1
using namespace std;

char W[MX];
int ls[MX << 2], rs[MX << 2], col_L[MX << 2],col_R[MX << 2], A[MX],B[MX];

void push_up(int rt) {
    ls[rt] = min(ls[rt << 1], ls[rt << 1 | 1]);
    rs[rt] = min(rs[rt << 1], rs[rt << 1 | 1]);
}

void push_down_L(int rt) {
    if(col_L[rt]) {
        col_L[rt << 1] += col_L[rt];
        col_L[rt << 1 | 1] += col_L[rt];
        ls[rt << 1] += col_L[rt];
        ls[rt << 1 | 1] += col_L[rt];
        col_L[rt] = 0;
    }
        if(col_R[rt]) {
        col_R[rt << 1] += col_R[rt];
        col_R[rt << 1 | 1] += col_R[rt];
        rs[rt << 1] += col_R[rt];
        rs[rt << 1 | 1] += col_R[rt];
        col_R[rt] = 0;
    }
}
void push_down_R(int rt) {
    if(col_R[rt]) {
        col_R[rt << 1] += col_R[rt];
        col_R[rt << 1 | 1] += col_R[rt];
        rs[rt << 1] += col_R[rt];
        rs[rt << 1 | 1] += col_R[rt];
        col_R[rt] = 0;
    }
       if(col_L[rt]) {
        col_L[rt << 1] += col_L[rt];
        col_L[rt << 1 | 1] += col_L[rt];
        ls[rt << 1] += col_L[rt];
        ls[rt << 1 | 1] += col_L[rt];
        col_L[rt] = 0;
    }
}
void build(int l, int r, int rt) {
    col_R[rt] = 0;
    col_L[rt] = 0;

    if(l == r) {
        ls[rt] = A[l];
        rs[rt] = B[l];
        return;
    }

    int m = (l + r) >> 1;
    build(lson);
    build(rson);
    push_up(rt);
}

void update_L(int L, int R, int d, int l, int r, int rt) {
    if(L <= l && r <= R) {
        ls[rt] += d;
        col_L[rt] += d;
        return;
    }

    int m = (l + r) >> 1;
    push_down_L(rt);
    if(L <= m) update_L(L, R, d, lson);
    if(R > m)  update_L(L, R, d, rson);
    push_up(rt);
}
void update_R(int L, int R, int d, int l, int r, int rt) {
    if(L <= l && r <= R) {
        rs[rt] += d;
        col_R[rt] += d;
        return;
    }

    int m = (l + r) >> 1;
    push_down_R(rt);
    if(L <= m) update_R(L, R, d, lson);
    if(R > m)  update_R(L, R, d, rson);
    push_up(rt);
}
int query_1(int l, int r, int rt) {
    if(l == r) {
        return l;
    }

    int m = (l + r) >> 1;
    push_down_L(rt);
    push_down_R(rt);

    if(rs[rt << 1] > 0) return query_1(lson);
    else return query_1(rson);
}

int query_2(int l, int r, int rt) {
    if(l == r) {
        return l;
    }

    int m = (l + r) >> 1;
    push_down_L(rt);
    push_down_R(rt);
    if((ls[rt << 1 | 1]-rs[rt << 1 | 1] )<= 2) return query_2(rson);
    else return query_2(lson);
}

int main() {
    int n, m, t, pos;
    while(scanf("%d%d", &n, &m)!=EOF) {
        scanf("%s", W + 1);

        int lsum = 0,rsum=0;
        for(int i = 1; i <= n; i++) {
            if(W[i]=='('){
                lsum++;
               }
            else{
                rsum++;
            }

            A[i] = lsum;
            B[i] = rsum;
        }
        build(root);

        while(m--) {
            scanf("%d", &t);
            //cout<<W[t]<<endl;
            if(W[t] == '(') {
                W[t] = ')'; update_L(t, n, -1, root);update_R(t, n, 1, root);
                t = query_1(root); W[t] = '('; update_L(t, n, 1, root);update_R(t, n, -1, root);
            } else {
                W[t] = '('; update_L(t, n, 1, root);update_R(t, n, -1, root);
                t = query_2(root) + 1; W[t] = ')'; update_L(t, n, -1, root);update_R(t, n, 1, root);
            }
            printf("%d\n", t);
        }
    }
}