n = int(input())
for _ in range(n):
    a,b,c = map(int,input().split())
    cnt = 0
    if b < c//2:
        cnt = b*3
    else:
        cnt = (c//2)*3
        b -= c//2
        if a < b//2:
            cnt += a*3
        else:
            cnt += (b//2)*3
    print(cnt)
