#!/bin/python3
t = int(input())
while t > 0:
	abc = list(map(int, input().split()))
	a, b, c = abc[0], abc[1], abc[2]
	ans = 3 * (min(b, int(c / 2)) + min(a, int((b - min(b, int(c / 2))) / 2)))
	print(int(ans))
	t -= 1

