#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define vint(a,n) vint a(n); rep(i, n) cin >> a[i];
#define vll(a,n) vll a(n); rep(i, n) cin >> a[i];
#define ALL(n) begin(n),end(n)
#define RALL(n) rbegin(n),rend(n)
#define MOD (1000000007)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
using vbool=vector<bool>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    int n; cin >> n;
    vll(a, n);

    ll neg=0, sum=0, min=INFL;
    rep(i, n){
        if(a[i]<0) neg++;
        sum += abs(a[i]);
        chmin(min, abs(a[i]));
    }

    if(neg%2==0) pr(sum);
    else pr(sum - 2*min);
    return 0;}
//Name: Baseball Simulation
//Level: 1
//Category: やるだけ
//Note:

/**
 * 仕様のとおりに実装する。
 *
 * オーダーは O(E)。
 * ただし、Eはイベントの個数。
 */
#include <iostream>
#include <string>

using namespace std;

bool solve() {
    int out = 0;
    int b1 = 0, b2 = 0, b3 = 0;
    int score = 0;
    while(out < 3) {
        string event;
        cin >> event;
        if(event == "HIT") {
            if(b3) ++score;
            b3 = b2; b2 = b1; b1 = 1;
        } else if(event == "HOMERUN") {
            score += b1+b2+b3+1;
            b1 = b2 = b3 = 0;
        } else if(event == "OUT") {
            ++out;
        }
    }
    cout << score << endl;
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);

    int T;
    cin >> T;
    while(T--) solve();
    return 0;
}