t = int(input())
out = []
for i in range(t):
    a, b, c = map(int, input().split())
    count = 0
    if min(a, b / 2) >= min(b, c / 2):
        if a == min(a, b / 2):
            count += 3 * a
        else:
            count += 3 * (b // 2)
        if b % 2 == 1:
            count += 3
    else:
        if b == min(b, c / 2):
            count += 3 * b
        else:
            count += 3 * (c // 2)
            if b - c // 2 >= 2:
                count += 3 * min(a, (b - c // 2) // 2)
    out.append(str(count))
print('\n'.join(out))