#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
using namespace std;
long long int MOD = 1000000007;
double eps = 1e-12;
void solve();
long long int gcd(long long int a, long long int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
void solve() {
  long long int n, q;
  cin >> n >> q;
  vector<long long int> v(n);
  for (long long int i = 0; i < n; i++) cin >> v[i];
  int flag = 0;
  int dp[n];
  long long int sum = v[0];
  dp[0] = 1;
  for (int i = 1; i < n; i++) {
    if (v[i] > v[i - 1]) {
      dp[i] = 1;
    } else
      dp[i] = 0;
    if (dp[i] == 1 && dp[i - 1] == 1)
      sum += v[i] - v[i - 1];
    else if (dp[i] == 1 && dp[i - 1] == 0)
      sum += v[i];
    else if (dp[i] == 0 && dp[i - 1] == 0)
      sum += -v[i] + v[i - 1];
    else if (dp[i] == 0 && dp[i - 1] == 1)
      sum -= v[i];
  }
  if (dp[n - 1] == 0) sum += v[n - 1];
  cout << sum << endl;
}
