for _ in range(int(input())):
    acc = 0
    h1, h2, h3 = list(map(int, input().split(' ')))
    while h3>1 and h2>0:
        h2 -= 1
        h3 -= 2
        acc +=3
    
    while h2>1 and h1>0:
        h2 -= 2
        h1 -= 1
        acc +=3
    
    print(acc)