#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 100;
long long ans = 0;
int a[maxn];
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    int n, q;
    scanf("%d%d", &n, &q);
    ans = 0;
    int x;
    a[0] = 0;
    int flag = 1;
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      if (a[i - 1] < a[i] && flag == 0) {
        ans -= a[i - 1];
        flag = 1;
      } else if (a[i - 1] > a[i] && flag == 1) {
        ans += a[i - 1];
        flag = 0;
      }
    }
    if (flag == 1) ans += a[n];
    printf("%lld\n", ans);
  }
}
