t = int(input())

for _ in range(t):
    a, b, c = map(int, input().split())

    n = a
    m = c // 2

    if m >= b:
        m = b
        n = 0
    else:
        n = min(a, (b - m)//2)

    print(3 * (n + m))

 				 		 		 	  			 				    		 	