import math
cases = int(input())
tests = []
for i in range(cases):
    tests.append(input().split())


def times(a,b,c):
    limit = min(math.floor(c/2), b)
    limit = limit+min(math.floor((b-limit)/2), a)
    return limit

for test in tests:
    print(times(int(test[0]), int(test[1]), int(test[2]))*3)
