import sys, math, bisect

def input():
    return sys.stdin.readline()[:-1]

def main():
    t = int(input())
    for _ in range(t):
        a, b, c = map(int,input().split())
        ans = 0
        for p in range(51):
            for q in range(51):
                if a-p >= 0 and b-2*p-q >= 0 and c - 2*q >= 0:
                    ans = max(ans,3*(p+q))
        print(ans)

if __name__ == '__main__':
    main()
