#include <bits/stdc++.h>
using namespace std;

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__)
#else
#define DEBUG(...) 6
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << "\033[1;35m" << s << "\033[0;32m = \033[33m" << x << "\033[0m\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {for (int i=0, b=0; i<(int)s.size(); i++) if (s[i] == '(' || s[i] == '{') b++; else
if (s[i] == ')' || s[i] == '}') b--; else if (s[i] == ',' && b == 0) {cerr << "\033[1;35m" << s.substr(0, i) << "\033[0;32m = \033[33m" << x << "\033[31m | "; debug(s.substr(s.find_first_not_of(' ', i + 1)), args...); break;}}

template<int MOD>
struct ModInt {
    long long v;
    ModInt(long long _v = 0) {v = (-MOD < _v && _v < MOD) ? _v : _v % MOD; if (v < 0) v += MOD;}
    ModInt& operator += (const ModInt &other) {v += other.v; if (v >= MOD) v -= MOD; return *this;}
    ModInt& operator -= (const ModInt &other) {v -= other.v; if (v < 0) v += MOD; return *this;}
    ModInt& operator *= (const ModInt &other) {v = v * other.v % MOD; return *this;}
    ModInt& operator /= (const ModInt &other) {return *this *= inverse(other);}
    bool operator == (const ModInt &other) const {return v == other.v;}
    bool operator != (const ModInt &other) const {return v != other.v;}
    friend ModInt operator + (ModInt a, const ModInt &b) {return a += b;}
    friend ModInt operator - (ModInt a, const ModInt &b) {return a -= b;}
    friend ModInt operator * (ModInt a, const ModInt &b) {return a *= b;}
    friend ModInt operator / (ModInt a, const ModInt &b) {return a /= b;}
    friend ModInt operator - (const ModInt &a) {return 0 - a;}
    friend ModInt power(ModInt a, long long b) {ModInt ret(1); while (b > 0) {if (b & 1) ret *= a; a *= a; b >>= 1;} return ret;}
    friend ModInt inverse(ModInt a) {return power(a, MOD - 2);}
    friend istream& operator >> (istream &is, ModInt &m) {is >> m.v; m.v = (-MOD < m.v && m.v < MOD) ? m.v : m.v % MOD; if (m.v < 0) m.v += MOD; return is;}
    friend ostream& operator << (ostream &os, const ModInt &m) {return os << m.v;}
};
using M = ModInt<1000000007>;

struct SegmentTree {
    struct Node {
        int ti, lazyTi, l, r;
        bool flag;
        M sum, sumsq, ans, lazy, cumsum, cumsumsq;

        void leaf(int val) {
            ti = lazyTi = 0;
            flag = false;
            sum = val;
            sumsq = M(val) * val;
            ans = lazy = cumsum = cumsumsq = 0;
        }

        void pull(const Node &a, const Node &b) {
            sum = a.sum + b.sum;
            sumsq = a.sumsq + b.sumsq;
            ti = max(a.ti, b.ti);
            ans = a.ans + b.ans + (ti - a.ti) * a.sumsq + (ti - b.ti) * b.sumsq;
        }

        void push(const Node &other) {
            if (flag) {
                cumsumsq += lazy * lazy * (other.lazyTi - lazyTi) + 2 * lazy * other.cumsum + other.cumsumsq;
                cumsum += lazy * (other.lazyTi - lazyTi) + other.cumsum;
            } else {
                cumsumsq = other.cumsumsq;
                cumsum = other.cumsum;
            }
            lazy += other.lazy;
            lazyTi = other.lazyTi;
            flag = true;
        }

        void apply() {
            // a^2 part
            ans += sumsq * (lazyTi - ti);
            // 2a * sum part
            ans += 2 * sum * cumsum;
            // sum^2 part
            ans += (r - l + 1) * cumsumsq;
            // update rest of stuff
            sumsq += 2 * sum * lazy + (r - l + 1) * lazy * lazy;
            sum += (r - l + 1) * lazy;
            ti = lazyTi;
            flag = false;
            lazy = cumsum = cumsumsq = 0;
        }
    };

    int n;
    vector<int> a;
    vector<Node> st;

    SegmentTree(int _n) : n(_n), a(n), st(4*n) {
        build(1, 0, n-1);
    }

    SegmentTree(const vector<int> &_a) : n((int) _a.size()), a(_a), st(4*n) {
        build(1, 0, n-1);
    }

    void build(int p, int l, int r) {
        st[p].l = l;
        st[p].r = r;
        if (l == r) {
            st[p].leaf(a[l]);
            return;
        }
        int m = (l + r) / 2;
        build(2*p, l, m);
        build(2*p+1, m+1, r);
        st[p].pull(st[2*p], st[2*p+1]);
    }

    void push(int p) {
        if (st[p].flag) {
            if (st[p].l != st[p].r) {
                st[2*p].push(st[p]);
                st[2*p+1].push(st[p]);
            }
            st[p].apply();
        }
    }

    Node query(int p, int i, int j) {
        push(p);
        if (st[p].l == i && st[p].r == j)
            return st[p];
        int m = (st[p].l + st[p].r) / 2;
        if (j <= m)
            return query(2*p, i, j);
        else if (i > m)
            return query(2*p+1, i, j);
        Node ret, ls = query(2*p, i, m), rs = query(2*p+1, m+1, j);
        ret.pull(ls, rs);
        return ret;
    }

    M query(int i, int j, long long ti) {
        Node ret = query(1, i, j);
        return ret.ans + (ti - ret.ti) * ret.sumsq;
    }

    void update(int p, int i, int j, int val, int ti) {
        if (st[p].l == i && st[p].r == j) {
            Node cur;
            cur.flag = true;
            cur.lazyTi = ti;
            cur.lazy = val;
            cur.cumsum = cur.cumsumsq = 0;
            st[p].push(cur);
            push(p);
            return;
        }
        push(p);
        int m = (st[p].l + st[p].r) / 2;
        if (j <= m) {
            update(2*p, i, j, val, ti);
            push(2*p+1);
        } else if (i > m) {
            push(2*p);
            update(2*p+1, i, j, val, ti);
        } else {
            update(2*p, i, m, val, ti);
            update(2*p+1, m+1, j, val, ti);
        }
        st[p].pull(st[2*p], st[2*p+1]);
    }

    void update(int i, int j, int val, int ti) {
        update(1, i, j, val, ti);
    }
};

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, m, q;
    cin >> n >> m >> q;
    vector<int> a(n);
    for (int i=0; i<n; i++)
        cin >> a[i];

    vector<array<int, 3>> modif;
    for (int i=0; i<m; i++) {
        int l, r, x;
        cin >> l >> r >> x;
        l--, r--;
        modif.push_back({l, r, x});
    }

    vector<vector<array<int, 4>>> queries(m + 1);
    for (int i=0; i<q; i++) {
        int l, r, x, y;
        cin >> l >> r >> x >> y;
        l--, r--;
        if (x > 0)
            queries[x-1].push_back({l, r, i, -1});
        queries[y].push_back({l, r, i, 1});
    }

    SegmentTree st(a);
    vector<M> ret(q);
    for (int i=0; i<m; i++) {
        for (auto [l, r, j, c] : queries[i])
            ret[j] += c * st.query(l, r, (long long) i + 1);
        st.update(modif[i][0], modif[i][1], modif[i][2], i + 1);
    }
    for (auto [l, r, j, c] : queries[m])
        ret[j] += c * st.query(l, r, (long long) m + 1);

    for (int i=0; i<q; i++)
        cout << ret[i] << "\n";

    return 0;
}
