#include <bits/stdc++.h>
using namespace std;
int boost = []() -> int {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  return 0;
}();
int clz(int type) {
  int num = 0;
  type |= 1;
  while (!(type & 0x80000000)) {
    num += 1;
    type <<= 1;
  }
  return num;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int q;
    cin >> q;
    vector<long long> a(n);
    for (long long &v : a) {
      cin >> v;
    }
    a.push_back(0);
    long long sum = 0;
    for (int i = 0; i < n; ++i) {
      sum += max(a[i] - a[i + 1], 0LL);
    }
    cout << sum << '\n';
    while (q--) {
      int l, r;
      cin >> l >> r;
      if (l == r) {
        cout << sum << "\n";
      } else if (l + 1 == r) {
      }
    }
  }
}
