#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n;
    scanf("%d 0", &n);
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
      scanf("%d", &a[i]);
    }
    vector<long long int> even(n + 1), odd(n + 1);
    odd[0] = -1e18;
    even[0] = 0;
    for (int i = 0; i < n; i++) {
      odd[i + 1] = max(odd[i], even[i] + a[i]);
      even[i + 1] = max(even[i], odd[i] - a[i]);
    }
    printf("%lld\n", max(even[n], odd[n]));
  }
}
