for _ in range(int(input().strip())):
    a,b,c = map(int,input().strip().split())
    if b <= 1 and c <= 1:
        print(str(0))
    elif b == 0:
        print(str(0))
    else:
        j = b
        x = 3*min(b,c//2)
        j -= min(b,c//2)
        x += 3*min(a,j//2)
        print(str(x))
