from sys import stdin

r = stdin.readline


def main():
    cases = int(r())
    for case in range(cases):
        a, b, c = map(int, r().strip().split())
        ans = 0
        mult = min(c//2, b)
        if b != 0: ans += ((mult*2) + mult)
        b-=mult
        mult = min(b//2, a)
        if a != 0: ans += ((mult*2) + mult)
        print(ans)

main()