#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, qq;
  cin >> n >> qq;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> diff(n);
  for (int i = 0; i < n - 1; i++) {
    diff[i] = a[i] - a[i + 1];
  }
  diff[n - 1] = a[n - 1];
  bool big = true;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    if (diff[i] > 0) {
      sum += diff[i];
    }
  }
  cout << sum << '\n';
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
