#include <iostream>

using namespace std;
const int maxn=10001;
int main()
{
    int t;
    while (cin>>t)
    {
        for (int tt=0;tt<t;tt++)
        {
            bool s[4*maxn]={false};
            int n,sum=0;
            cin>>n;
            for (int i=0;i<4*n;i++)
            {
                char ch;
                cin>>ch;
                if (ch=='Y')
                {
                    s[i]=true;
                    sum++;
                }
            }

            int total=n,ct=0;
            int now=0;
            if (sum!=0)
            {
                bool f=false;
                while ((!s[now])&&(!s[2*n+now])) now++;
                bool ff=false,fff=false;
                if (s[now])
                {
                    f=true;
                    total++;    ct++;
                    ff=true;
                }
                if (s[2*n+now])
                {   total++;    ct++;
                    f=false;
                    fff=true;
                    if (!ff)
                    {
                        total++;
                        ff=true;
                    }
                }
                now++;
                if ((now%2==0)&&(now<2*n)&&((s[now])||(s[2*n+now])))
                {
                    if (s[now])
                    {
                        ct++;
                        f=true;
                        if (!ff)
                        {
                            total++;
                            ff=true;
                        }
                    }
                    if (s[2*n+now])
                    {
                        ct++;
                        f=false;
                        if (!fff)
                        {
                            total++;
                            if (!ff)
                            {
                                total++;
                            }
                        }
                    }
                    now++;
                }
                while (ct!=sum)
                {

                    while ((!s[now])&&(!s[2*n+now])) now++;
                    f=false;
                    bool sz=false,xz=false;
                    if (s[now])
                    {
                        total++;    ct++;
                        sz=true;
                        f=true;
                    }
                    if (s[2*n+now])
                    {
                        xz=true;
                        total++;    ct++;
                    }
                    now++;
                    if ((now%2==0)&&(now<2*n)&&((s[now])||(s[2*n+now])))
                    {
                        if (s[now])
                        {
                            ct++;
                            if (!sz)
                            {
                                total++;
                                f=true;
                            }
                        }
                        if (s[2*n+now])
                        {
                            ct++;
                            if(!xz)
                            {
                                total++;
                            }
                        }
                        now++;
                    }
                }
                if (!f) total++;
            }
            cout << total <<endl;

        }
    }
    return 0;
}

Measured memory_bytes: 0