T = int(input())
ans = []
for i in range(T):
    arr = list(map(int, input().split()))
    a, b, c = arr[0], arr[1], arr[2]
    v1 = min(a, b // 2) #start with first
    v2 = min(b, c // 2) #start with second
    s1 = 0
    s1 += v1 * 3
    b1 = b - v1 * 2
    s1 += min(b1, c // 2) * 3
    s2 = 0
    s2 += v2 * 3
    b2 = b - v2
    s2 += min(a, b2 // 2) * 3
    ans.append(max(s1, s2))
for el in ans:
    print(el)