#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
const long INF = LONG_LONG_MAX, MOD = 1e9 + 7;
using namespace std;
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&...args) {
  const char *comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
void solve() {
  long long n, i, j, q, mx = 0;
  cin >> n >> q;
  long long a[n], dp[n][2];
  for (int i = 0; i < n; ++i) cin >> a[i];
  mx = a[0];
  for (i = 1; i < n; ++i) mx += max(a[i] - a[i - 1], 0LL);
  cout << mx;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(11);
  long long t;
  cin >> t;
  while (t--) {
    solve();
    cout << '\n';
  }
  return 0;
}
