#include <bits/stdc++.h>
using namespace std;
vector<long long> v;
vector<long long> prefix1, prefix2;
map<long long, long long> dp1, dp2;
long long dp(long long n, bool b) {
  if (b == 0 && dp1.count(n) > 0) return dp1[n];
  if (b == 1 && dp2.count(n) > 0) return dp2[n];
  if (n == v.size()) return 0;
  if (b == 0) return dp1[n] = max(dp(n + 1, b), v[n] + dp(n + 1, !b));
  if (b == 1) return dp2[n] = max(dp(n + 1, b), -v[n] + dp(n + 1, !b));
  return 0;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long t, n, q, a, b, prev = 0, x, res = 0;
  cin >> t;
  while (t--) {
    res = 0;
    dp1.clear();
    dp2.clear();
    cin >> n >> q;
    v.resize(n);
    for (long long i = 0; i < n; i++) cin >> v[i];
    res = dp(0, 0);
    cout << res << endl;
    for (long long i = 0; i < q; i++) {
      cin >> a >> b;
      cout << res << endl;
    }
  }
}
