#include <bits/stdc++.h>
using namespace std;
#define MAXNO 200
int mem[MAXNO][MAXNO][2];
int get(vector<int> v, int s, int e, int findMax) {
if(mem[s][e][findMax] != -1) return mem[s][e][findMax];
if(e == s)
return mem[s][e][findMax] = v[s];
else if(e - s == 1)
return mem[s][e][findMax] = v[s] - v[e];
int a = v[s] - get(v, s + 1, e, findMax);
int b = v[s] - v[s + 1] - get(v, s + 2, e, findMax);
return mem[s][e][findMax] = (findMax ? max(a, b) : min(a, b));
}
void reset() {
for(int j = 0; j < MAXNO; j++) {
for(int k = 0; k < MAXNO; k++) {
for(int l = 0; l < 2; l++) {
mem[j][k][l] = -1;
}
}
}
}
int main()
{
string tt;
getline(cin,tt);
stringstream st(tt);
int t;
st >> t;
while(t--) {
string s;
getline(cin,s);
stringstream ss(s);
int ii;
vector<int> v;
while(ss >> ii) {
v.push_back(ii);
}
if(v.size() == 1) {
cout << v[0] << endl;
} else {
int ans = INT_MIN;
for(int i = 0; i < v.size() - 1; i++) {
reset();
int left = get(v, 0, i, 1);
reset();
int right = get(v, i + 1, v.size() - 1, 0);
ans = max(ans, left - right);
}
cout << ans << endl;
}
}
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgojZGVmaW5lIE1BWE5PIDIwMAoKaW50IG1lbVtNQVhOT11bTUFYTk9dWzJdOwoKaW50IGdldCh2ZWN0b3I8aW50PiB2LCBpbnQgcywgaW50IGUsIGludCBmaW5kTWF4KSB7CiAgICBpZihtZW1bc11bZV1bZmluZE1heF0gIT0gLTEpIHJldHVybiBtZW1bc11bZV1bZmluZE1heF07CiAgICAKICAgIGlmKGUgPT0gcykKICAgICAgICByZXR1cm4gbWVtW3NdW2VdW2ZpbmRNYXhdID0gdltzXTsKICAgIGVsc2UgaWYoZSAtIHMgPT0gMSkKICAgICAgICByZXR1cm4gbWVtW3NdW2VdW2ZpbmRNYXhdID0gdltzXSAtIHZbZV07CiAgICAKICAgIGludCBhID0gdltzXSAtIGdldCh2LCBzICsgMSwgZSwgZmluZE1heCk7CiAgICBpbnQgYiA9IHZbc10gLSB2W3MgKyAxXSAtIGdldCh2LCBzICsgMiwgZSwgZmluZE1heCk7CiAgICAKICAgIHJldHVybiBtZW1bc11bZV1bZmluZE1heF0gPSAoZmluZE1heCA/IG1heChhLCBiKSA6IG1pbihhLCBiKSk7Cn0KCnZvaWQgcmVzZXQoKSB7CiAgICBmb3IoaW50IGogPSAwOyBqIDwgTUFYTk87IGorKykgewogICAgICBmb3IoaW50IGsgPSAwOyBrIDwgTUFYTk87IGsrKykgewogICAgICAgIGZvcihpbnQgbCA9IDA7IGwgPCAyOyBsKyspIHsKICAgICAgICAgIG1lbVtqXVtrXVtsXSA9IC0xOyAgCiAgICAgICAgfQogICAgICB9CiAgICB9Cn0KCmludCBtYWluKCkKeyAgCiAgICBzdHJpbmcgdHQ7CiAgICBnZXRsaW5lKGNpbix0dCk7CiAgICAKICAgIHN0cmluZ3N0cmVhbSBzdCh0dCk7CiAgICBpbnQgdDsKICAgIHN0ID4+IHQ7CiAgICAKICAgIHdoaWxlKHQtLSkgewogICAgICAgIHN0cmluZyBzOwogICAgICAgIGdldGxpbmUoY2luLHMpOwogICAgICAgIAogICAgICAgIHN0cmluZ3N0cmVhbSBzcyhzKTsKICAgICAgICAKICAgICAgICBpbnQgaWk7CiAgICAgICAgdmVjdG9yPGludD4gdjsKICAgICAgICAKICAgICAgICB3aGlsZShzcyA+PiBpaSkgewogICAgICAgICAgICB2LnB1c2hfYmFjayhpaSk7CiAgICAgICAgfQogICAgICAgIAogICAgICAgIGlmKHYuc2l6ZSgpID09IDEpIHsKICAgICAgICAgICAgY291dCA8PCB2WzBdIDw8IGVuZGw7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgaW50IGFucyA9IElOVF9NSU47CgogICAgICAgICAgICBmb3IoaW50IGkgPSAwOyBpIDwgdi5zaXplKCkgLSAxOyBpKyspIHsKICAgICAgICAgICAgICByZXNldCgpOwogICAgICAgICAgICAgIGludCBsZWZ0ID0gZ2V0KHYsIDAsIGksIDEpOwogICAgICAgICAgICAgIAogICAgICAgICAgICAgIHJlc2V0KCk7CiAgICAgICAgICAgICAgaW50IHJpZ2h0ID0gZ2V0KHYsIGkgKyAxLCB2LnNpemUoKSAtIDEsIDApOwogICAgICAgICAgICAgIAogICAgICAgICAgICAgIGFucyA9IG1heChhbnMsIGxlZnQgLSByaWdodCk7CiAgICAgICAgICAgIH0KICAgIAogICAgICAgICAgICBjb3V0IDw8IGFucyA8PCBlbmRsOyAgIAogICAgICAgIH0KICAgIH0KfQ==