import sys
#sys.stdin = open('in', 'r')
n = int(input())
for i in range(n):
    a,b,c = map(int, input().split())
    r = 0
    x1 = min(c // 2, b)
    b -= x1
    x2 = min(b // 2, a)
    print((x1 + x2) * 3)

#a = [int(x) for x in input().split()]




#sys.stdout.write('YES\n')
#sys.stdout.write(f'{res}\n')
#sys.stdout.write(f'{y1} {x1} {y2} {x2}\n')
