import sys
from math import sqrt, floor, factorial
from collections import deque, Counter
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))

def solve():
	for _ in range(int(inp())):
		a, b, c = read(); s =0
		if b:
			c = min(c-(c%2), b*2)
			s += c + c//2
			b -= c//2
			b = min(b-(b%2), a*2)
			s += b + b//2
			print(s)
		else:
			print(s) 


if __name__ == "__main__":
	solve()