#include <bits/stdc++.h>

using namespace std;

// make sure modify 0LL + , 1LL * , overflow when remove define
#define int long long
#define _3bkarm cin.tie(NULL); cout.tie(NULL); ios::sync_with_stdio(false);

struct BIT {
    int n;
    vector<int> tree;

    void init(int _n) {
        n = _n, tree.assign(_n, 0);
    }

    void add(int at, int value) {
        for (int i = at + 1; i <= n; i += i & -i)
            tree[i - 1] += value;
    }

    int sum(int exc) {
        int ans = 0;
        for (int i = exc; i > 0; i -= i & -i)
            ans += tree[i - 1];
        return ans;
    }

    int sum(int inc, int exc) {
        return sum(exc) - sum(inc);
    }

    int search(int value) {
        int sum = 0, pos = -1;
        // decrease
        for (int i = 25; i >= 0; --i) {
            if (pos + (1 << i) < n and sum + tree[pos + (1 << i)] < value)
                sum += tree[pos + (1 << i)], pos += (1 << i);
        }
        // pos : less than val
        return pos + 1;
    }
};

vector<vector<int>> adj;

int ct = 0;
vector<bool> vis;
vector<int> in, out;
void dfs(int u) {
    vis[u] = true;
    in[u] = ct++;
    for (int ch : adj[u])
        dfs(ch);
    out[u] = ct;
}

void get_shit_done() {
    int n, q;
    cin >> n >> q;

    string s;
    cin >> s;

    vector<int> a(2 * n);
    for (int i = 0; i < 2 * n; ++i)
        cin >> a[i];

    adj.assign(2 * n, {});
    vector<int> close(2 * n), t;
    for (int i = 0; i < 2 * n; ++i) {
        if (s[i] == '(') {
            if ( not t.empty() )
                adj[t.back()].push_back(i);
            t.push_back(i);
        } else {
            close[t.back()] = i;
            t.pop_back();
        }
    }

    BIT tree;
    tree.init(2 * n + 1);

    ct = 0;
    in.assign(2 * n, 0);
    out.assign(2 * n, 0);
    vis.assign(2 * n, false);
    for (int i = 0; i < 2 * n; ++i) {
        if (not vis[i] and s[i] == '(')
            dfs(i);
    }

    while (q--) {
        int op;
        cin >> op;
        if (op == 1) {
            int l1, r1, l2, r2, x;
            cin >> l1 >> r1 >> l2 >> r2 >> x;
            --l1, --r1, --l2, --r2;
            if (l1 > l2) {
                swap(l1, l2);
                swap(r1, r2);
            }
            if ( l2 < r1 )
                tree.add(in[l1], x);
            else
                tree.add(in[l2], x);
        } else {
            int l, r;
            cin >> l >> r;
            --l, --r;
            cout << a[l] + tree.sum(in[l], out[l]) << '\n';
        }
    }
}

signed main() {
    _3bkarm

    int ts = 1;
    cin >> ts;
    while (ts--) {
        get_shit_done();
    }

    return 0;
}