def main(a, b, c):
    sum = 0
    while True:
        if a < 1:
            if b < 1:
                break
            else:
                if c < 2:
                    break
        elif a >= 1:
            if b < 2:
                if b >= 1:
                    if c < 2:
                        break
                else:
                    break
        if b <= c:
            b = b - 1
            c = c - 2
            sum = sum + 3
        else:
            a = a - 1
            b = b - 2
            sum = sum + 3
    return sum


if __name__ == '__main__':
    t = int(input())
    for t_itr in range(t):
        abc = list(map(int, input().rstrip().split()))
        a = abc[0]
        b = abc[1]
        c = abc[2]
        res = main(a, b, c)
        print(res)
