for _ in range(int(input())):
    a, b, c = list(map(int, input().split()))
    cnt = 0
    s = min(b, c//2)
    cnt += s*3
    c -= (s*2)
    b -= s
    s = min(a, b//2)
    cnt += s*3
    print(cnt)
