t = int(input())
for i in range(t):
    a, b, c = map(int,input().split())
    if b > c // 2:
        n1 = c // 2
    else:
        n1 = b
    b -= n1
    if a > b // 2:
        n2 = b // 2
    else:
        n2 = a
    print(3*(n1+n2))