#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n, q;
    cin >> n >> q;
    long long a[n + 1];
    for (int i = 1; i <= n; ++i) cin >> a[i];
    long long ans = a[1];
    for (int i = 2; i <= n; ++i) ans += max(0LL, a[i] - a[i - 1]);
    cout << ans << endl;
  }
}
