import random


def get_many_ints():
    return map(int, input().split())


def get_int():
    return int(input())


t = get_int()
for _ in range(t):
    a, b, c = get_many_ints()
    best = 0
    for i in range(100):
        for j in range(100):
            if a >= i and b >= 2 * i + j and c >= 2 * j:
                best = max(best, i + j)
    print(3 * best)
