def stones(a, b, c):
    r = 0
    while c >= 2:
        if b >= 1:
            c -= 2
            b -= 1
            r += 3
        else:
            break
    while b>= 2:
        if a >= 1:
            a -= 1
            b -= 2
            r += 3
        else:
            break
    return r



def main():
    for i in range(int(input())):
        a, b, c = map(int,input().split(" "))
        print(stones(a,b,c))
    
    

if __name__ == "__main__":
    main()