from sys import stdin
import math

for _ in range(int(stdin.readline())):
        a, b, c = list(map(int, stdin.readline().rstrip().split()))
        s = 0
        o2 = min(b, c//2)
        s += o2*3
        o1 = min(a, (b - o2)//2)
        s += o1*3

        print(s)

        