#include <iostream>
#include <vector>
#include <climits>
using namespace std;
// Function to calculate the smallest maximum element after skipping one update
long long skipUpdate(int N, int Q, vector<int>& A, vector<vector<int>>& updates) {
// Step 1: Create a difference array for all updates
vector<long long> diff(N + 2, 0);
// Apply all updates to the difference array
for (const auto& update : updates) {
int L = update[0];
int R = update[1];
int X = update[2];
diff[L] += X;
if (R + 1 <= N) {
diff[R + 1] -= X;
}
}
// Step 2: Compute the fully updated array
vector<long long> fullArray(N + 1, 0);
fullArray[1] = A[0] + diff[1];
for (int i = 2; i <= N; ++i) {
diff[i] += diff[i - 1];
fullArray[i] = A[i - 1] + diff[i];
}
// Step 3: Calculate prefix and suffix maximums
vector<long long> prefixMax(N + 2, LLONG_MIN);
vector<long long> suffixMax(N + 2, LLONG_MIN);
// Prefix maximums: max up to index i
for (int i = 1; i <= N; ++i) {
prefixMax[i] = max(prefixMax[i - 1], fullArray[i]);
}
// Suffix maximums: max from index i to end
for (int i = N; i >= 1; --i) {
suffixMax[i] = max(suffixMax[i + 1], fullArray[i]);
}
// Step 4: Iterate through each update and calculate the result
long long minMaxValue = LLONG_MAX;
for (const auto& update : updates) {
int L = update[0];
int R = update[1];
int X = update[2];
// Calculate the maximum without applying this update
long long currentMax = LLONG_MIN;
// Left part before L
if (L > 1) {
currentMax = max(currentMax, prefixMax[L - 1]);
}
// Right part after R
if (R < N) {
currentMax = max(currentMax, suffixMax[R + 1]);
}
minMaxValue = min(minMaxValue, currentMax);
}
return minMaxValue;
}
int main() {
int T;
cin >> T;
while (T--) {
int N, Q;
cin >> N >> Q;
vector<int> A(N);
for (int i = 0; i < N; ++i) {
cin >> A[i];
}
vector<vector<int>> updates(Q, vector<int>(3));
for (int i = 0; i < Q; ++i) {
cin >> updates[i][0] >> updates[i][1] >> updates[i][2];
}
cout << skipUpdate(N, Q, A, updates) << endl;
}
return 0;
}