import sys
input = sys.stdin.buffer.readline

t = int(input())
for i in range(t):
    a, b, c = [int(item) for item in input().split()]
    ans = 0
    for i in range(55):
        for j in range(55):
            if i <= a and i * 2 + j <= b and j * 2 <= c:
                ans = max(ans, i * 3 + j * 3)
    print(ans)