import sys
input = sys.stdin.readline

def solve(a, b, c):
    if c >= b >= 1 and c >= 2:
        return 3 + solve(a, b - 1, c - 2)
    elif b >= 2 and a >= 1:
        return 3 + solve(a - 1, b - 2, c)
    elif b >= 1 and c >= 2:
        return 3 + solve(a, b - 1, c - 2)
    else:
        return 0



def main():
    t = int(input())
    for _ in range(t):
        a, b, c = [int(x) for x in input().split()]
        print(solve(a, b, c))






if __name__ == '__main__':
    main()


