#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define mod 998244353
#define f0(n) for(int i=0;i<n;i++) 
#define vi vector<int>
#define vs vector<string>
#define mp make_pair 
#define pb push_back
#define rt return
#define sumof(arr) accumulate(arr,arr+n,0);
int lcm(int a,int b)
{
  return (a*b)/__gcd(a,b);
}
//PERMUTATIONS OF A STRING 

signed main() {
 
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("out.txt","w",stdout);
  #endif
  int t;
  cin>>t;
  while(t--)
  {
    int a,b,c,ans=0;
    cin>>a>>b>>c;

    if(b>c)
    {
      //cout<<b<<" "<<c<<"\n";
      if(b/2>=a)
      {
        ans+=(3*a);
        b-=2*a;

      }
      else
      {
        ans+=(b/2)*3;
        b=b%2;
      }
      if(b>0)
      {
        if(c/2>=b)
        {
          ans+=(3*b);
          c-=2*b;

        } 
        else
        {
          ans+=(c/2)*3;

        }
       
      }
       cout<<ans<<"\n";
    }
    else
    {
      if(c/2>=b)
      {
        ans+=(3*b);
        c-=2*b;
        b=0;

      }
      else
      {
        ans+=(c/2)*3;
        b-=(c/2);

      }
      if(b>0)
      {
        if(b/2>=a)
      {
        ans+=(3*a);
        b-=2*a;

      }
      else
      {
        ans+=(b/2)*3;
        b=b%2;
      } 
      }
      cout<<ans<<"\n";
    }
  }
  
  
  
  

  return 0;
}
