import itertools
def main():
    n = int(input())
    for i in range(n):
        a,b,c = [int(v) for v in input().split()]
        c1 = min(b, c//2)
        c11 = min(a, (b-c1)//2)
        r1 = c1*3 + c11*3

        c2 = min(a, b // 2)
        c21 = min(c//2, (b - c2*2))
        r2 = c2 * 3 + c21 * 3
        print(max(r1, r2))

if __name__ == "__main__":
    main()
