def solution(t):
    total_arr = []
    for i in range(t):
        a, b, c = map(int, input().split())
        t = min(b, c// 2)
        total = 3*t
        t = min(a, (b-t)//2)
        total += 3*t
        total_arr.append(total)
    print("\n".join(map(str, total_arr)))
        



def main():
    t = int(input())
    solution(t)


if __name__ == "__main__":
    main()
