t = int(input())

for i in range(t):
    alist = list(map(int,input().split()))
    flag = 0
    ans = 0
    while alist[2]>1 and alist[1]>0:
        ans += 3
        alist[2] -=2
        alist[1] -=1
    while alist[1]>1 and alist[0]>0:
        ans+= 3
        alist[1] -= 2
        alist[0] -= 1
    print(ans)


