# https://vjudge.net/contest/339915#problem/D
import math


def init():
    t = int(input())
    for i in range(t):
        h1, h2, h3 = map(lambda x: int(x), input().split(' '))
        count = 0

        second_move_count = min(h2, math.floor(h3 / 2))
        count += 3 * second_move_count
        h2 -= second_move_count
        first_move_count = min(h1, math.floor(h2 / 2))
        count += 3 * first_move_count

        print(count)


init()

      	   		   		 	   		 	 			