
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int t=0;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        int c0=0,c1=0,c2=0;
        for(int i=0;i<n;i++)
        {
            int x;
            cin>>x;
            if(x%3==0)
                c0++;
            else if(x%3==1)
                c1++;
            else
                c2++;
        }
        int target=n/3;
        int answer=0;
        while(min(c0,min(c1,c2))!=n/3)
        {
            if(c0>n/3)
            {
                c1++;
                c0--;
                answer++;
            }
            if(c1>n/3)
            {
                c1--;
                c2++;
                answer++;
            }
            if(c2>n/3)
            {
                c2--;
                c0++;
                answer++;
            }
        }
        cout<<answer<<endl;
    }
return 0;
}
