import sys
input = sys.stdin.readline

t = int(input())
for i in range(t):
    delta = [int(x) for x in input().split()]
    a = delta[0]
    b = delta[1]
    c = delta[2]
    one = 0
    two = 0
    t1 = int(c//2)
    t2 = b
    two = min(t1,t2)
    b-=two
    c-=2*two
    t3 = int(b//2)
    t4 = a
    one = min(t3,t4)
    print(3*(one+two))
    
