Problem: This is the easy version of the problem. The difference between the versions is that the easy version has no swap operations. You can make hacks only if all versions of the problem are solved.

Pikachu is a cute and friendly pokémon living in the wild pikachu herd.

But it has become known recently that infamous team R wanted to steal all these pokémon! Pokémon trainer Andrew decided to help Pikachu to build a pokémon army to resist.

First, Andrew counted all the pokémon — there were exactly n pikachu. The strength of the i-th pokémon is equal to a_i, and all these numbers are distinct.

As an army, Andrew can choose any non-empty subsequence of pokemons. In other words, Andrew chooses some array b from k indices such that 1 ≤ b_1 < b_2 < ... < b_k ≤ n, and his army will consist of pokémons with forces a_{b_1}, a_{b_2}, ..., a_{b_k}.

The strength of the army is equal to the alternating sum of elements of the subsequence; that is, a_{b_1} - a_{b_2} + a_{b_3} - a_{b_4} + ....

Andrew is experimenting with pokémon order. He performs q operations. In i-th operation Andrew swaps l_i-th and r_i-th pokémon.

Note: q=0 in this version of the task.

Andrew wants to know the maximal stregth of the army he can achieve with the initial pokémon placement. He also needs to know the maximal strength after each operation.

Help Andrew and the pokémon, or team R will realize their tricky plan!

Input

Each test contains multiple test cases.

The first line contains one positive integer t (1 ≤ t ≤ 10^3) denoting the number of test cases. Description of the test cases follows.

The first line of each test case contains two integers n and q (1 ≤ n ≤ 3 ⋅ 10^5, q = 0) denoting the number of pokémon and number of operations respectively.

The second line contains n distinct positive integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ n) denoting the strengths of the pokémon.

i-th of the last q lines contains two positive integers l_i and r_i (1 ≤ l_i ≤ r_i ≤ n) denoting the indices of pokémon that were swapped in the i-th operation.

It is guaranteed that the sum of n over all test cases does not exceed 3 ⋅ 10^5, and the sum of q over all test cases does not exceed 3 ⋅ 10^5. 

Output

For each test case, print q+1 integers: the maximal strength of army before the swaps and after each swap.

Example

Input


3
3 0
1 3 2
2 0
1 2
7 0
1 2 5 4 3 6 7


Output


3
2
9

Note

In third test case we can build an army in such way: [1 2 5 4 3 6 7], its strength will be 5−3+7=9.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using db = double;
using VI = vector<int>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
using VS = vector<string>;
const int inf = 0x3f3f3f3f;
const int rinf = 0xc0c0c0c0;
const LL MOD = 1e9 + 7;
const LL LMAX = 0x7fffffffffffffff;
const LL LMIN = 0x8000000000000000;
template <typename T1, typename T2, typename T3>
struct Tup {
  T1 first;
  T2 second;
  T3 third;
  inline bool operator<(const Tup<T1, T2, T3> &b) {
    if (this->first != b.first) {
      if (this->second != b.second)
        return this->second < b.second;
      else
        return this->third < b.third;
    }
    return this->first < b.first;
  }
  friend ostream &operator<<(ostream &out, const Tup<T1, T2, T3> &tup) {
    out << tup.first << " " << tup.second << " " << tup.third;
    return out;
  }
  void disp() {
    cout << "(" << this->first << ", " << this->second << ", " << this->third
         << ")\n";
  }
};
template <typename T>
void print(vector<vector<T>> a) {
  for (int i = 0; i < a.size(); ++i) {
    for (int j = 0; j < a[i].size(); ++j)
      cout << a[i][j] << (j == ((int)a[i].size()) - 1 ? '\n' : ' ');
  }
}
template <typename T>
void print(T *a, int len) {
  for (int i = 0; i < len; ++i) cout << a[i] << " ";
  cout << endl;
}
template <typename T>
void print(T **a, int row, int col) {
  for (int i = 0; i < row; ++i) {
    for (int j = 0; j < col; ++j)
      cout << a[i][j] << (j == col - 1 ? '\n' : ' ');
  }
}
template <typename T1, typename T2>
void print(const vector<pair<T1, T2>> a) {
  for (auto &e : a) cout << "(" << e.first << ", " << e.second << ")\n";
}
template <typename... Args>
void _SHOW_ALL(Args... args) {}
template <typename T, typename... Args>
void _SHOW_ALL(T val, Args... args) {
  cout << val << ", ";
  _SHOW_ALL(args...);
}
template <typename T, typename... Args>
void to_brackets(T val, Args... args) {
  cout << "(";
  _SHOW_ALL(val, args...);
  cout << ")\n";
}
template <typename... Args>
void wprint(Args... args) {
  cout << '\n';
}
template <typename T, typename... Args>
void wprint(T val, Args... args) {
  cout << val << " ";
  wprint(args...);
}
inline int read() {
  char c = getchar();
  int x = 0, f = 1;
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
  return f * x;
}
inline LL readl() {
  char c = getchar();
  LL x = 0, f = 1;
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
  return f * x;
}
void write(int a) {
  if (a < 0) putchar('-'), a = -a;
  if (a >= 10) write(a / 10);
  putchar(a % 10 + 48);
}
const int maxn = 3e5 + 50;
LL f[maxn];
void solve() {
  int n = read(), q = read();
  for (int i = 1; i <= n; ++i) f[i] = readl();
  f[0] = f[n + 1] = -1;
  LL ans(0);
  for (int i = 1; i <= n; ++i) {
    if (f[i - 1] > f[i] && f[i] < f[i + 1]) ans -= f[i];
    if (f[i - 1] < f[i] && f[i] > f[i + 1]) ans += f[i];
  }
  cout << ans << '\n';
  auto &&add = [&](int i) {
    if (i == 0 or i == n + 1) return;
    if (f[i - 1] > f[i] and f[i] < f[i + 1]) ans -= f[i];
    if (f[i - 1] < f[i] and f[i] > f[i + 1]) ans += f[i];
  };
  auto &&del = [&](int i) {
    if (i == 0 or i == n + 1) return;
    if (f[i - 1] > f[i] and f[i] < f[i + 1]) ans += f[i];
    if (f[i - 1] < f[i] and f[i] > f[i + 1]) ans -= f[i];
  };
  for (int i = 0; i < q; ++i) {
    int l = read(), r = read();
    del(l - 1), del(l), del(l + 1);
    if (l != r) {
      if (r - 1 != l + 1 and r - 1 != l) del(r - 1);
      if (r != l + 1) del(r);
      del(r + 1);
    }
    swap(f[l], f[r]);
    add(l - 1), add(l), add(l + 1);
    if (l != r) {
      if (r - 1 != l + 1 and r - 1 != l) add(r - 1);
      if (r != l + 1) add(r);
      add(r + 1);
    }
    cout << ans << '\n';
  }
}
int main() {
  int t = read();
  while (t--) solve();
  return 0;
}