n_lines = int(input())
res_arr = []
for i in range(n_lines):
    nums = [int(i) for i in input().split()]
    times1 = min(nums[1], nums[2] // 2)
    remaining1 = nums[1]-times1
    times2 = min(nums[0], remaining1//2)
    res = (times1+times2) * 3
    res_arr.append(res)
for res in res_arr:
    print(res)