#include<iostream>
#include<vector>
#define ll long long
using namespace std;

vector<int> open;
vector<int> a;
vector<ll int> out;

vector<vector<ll int>> matr;

void changeState(ll i, ll j, int state)
{
    //cout << i << " " << j << endl;
    for(int x = i; x <= j; x++)
    {
        open[x] = state;
        //cout << "resturant number "<< x << " has state: " << state << endl;
    }

}
 int findRout(int s, int e)
 {
    int connections = 0, clossest = INT_MAX, curr = s, res = 0;
     while(curr != e)
     {

        for(int i = 0; i < open.size(); i++)
        {
            if(matr[curr][i] != -1 && abs(e - matr[curr][i]) < clossest)
            {
                clossest = i;
            }
        }
        res = res ^ matr[curr][clossest];
        curr = clossest;
    }
    return res;
 }

int findHappy(int j, int i)
{
    int res = 0, temp = 0;
    if(i <= j || open[i] == 2 || open[j] == 2)
    {
        return 0;
    }

    if(j + 1 == i)
    {
        for(int x = j + 1; x <= i; x++)
        {
            if(open[x] == 1 && open[x - 1] == 1)
            {
                res += matr[x - 1][x];
            }
        }
    }
    if(j + 1 < i)
    {
        temp = findRout(j, i);
    }
    return res + temp;
}

vector<ll int> happy (int N, int Q, vector<int> u, vector<int> v, vector<int> h, vector<int> t, vector<int> l, vector<int> r)
{
    int res;
    open.resize(N);
    matr.resize(N);
    //cout<<61<<endl;
    for(int i = 0; i < N; i++)
    {
        open[i] = 2;
        matr[i].resize(N);
        for(int j = 0; j < N; j++)
        {
            matr[i][j] = -1;
        }
        matr[u[i]][v[i]] = h[i];
        //matr[v[i]][u[i]] = h[i];
    }
    ////cout<<69<<endl;
    for(int i = 0; i < Q; i++)
    {
        changeState(l[i], r[i], t[i]);
        res = 0;
        for(int j = 0; j < N; j++)
        {
            for(int k = 0; k < N; k++)
            {
                res += findHappy(j, k);
            }
        }
            out.push_back(res);
    }
    return out;
}

int main()
{
    int n, k;
    cin >> n >> k;
    a.resize(n);
    vector<int> b(n), c(n), d(k), e(k), f(k);
    int test = 0;

    for(int  i = 0; i < n - 1; i++)
    {
        cin >> a[i];
    }
    for(int  i = 0; i < n - 1; i++)
    {
        cin >> b[i];
    }
    for(int  i = 0; i < n - 1; i++)
    {
        cin >> c[i];
    }
    for(int  i = 0; i < k   ; i++)
    {
        cin >> d[i];
    }
    for(int  i = 0; i < k; i++)
    {
        cin >> e[i];
    }
    for(int  i = 0; i < k; i++)
    {
        cin >> f[i];
    }
    vector<ll int> out = happy(n, k, a, b, c, d, e, f);
    for(int i = 0; i < out.size(); i++)
    {
        cout << out[i] << " ";
    }
}
