package com.company;
import java.io.*;
import java.io.InputStreamReader;
import java.util.*;
/**
meng3.wei 2020.05.06
3
3
NNNS
SN
NNSS
2
NS
SN
2
NN
SS
#1 8
#2 2
#3 4
*/
public class 锯齿磁铁 {
public static int T,N;
public static long[] sarr,narr;
public static long[] result;
static int S_M=1000000007;
public static void main(String[] args) throws Exception{
//System.setIn(new FileInputStream("D:\\sw_case\\38\\test_input.txt"));
//System.setIn(new FileInputStream("D:\\sw_case\\38\\sample_input.txt"));
System.setIn(new FileInputStream("D:\\sw_case\\38\\eval_input.txt"));
BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
T=Integer.parseInt(reader.readLine());//用例的个数
result=new long[T];
for (int i = 0; i <T ; i++) {
N=Integer.parseInt(reader.readLine());//齿轮的个数
sarr=new long[N];
narr=new long[N];
long[] nsarr=new