n = int(input())
out = []
for i in range(n):
    a, b, c = map(int, input().split())
    if b >= c//2:
        if a >= (b-c//2)//2:
            out.append((c // 2 + (b - c // 2) // 2) * 3)
        else:
            out.append((c//2+a)*3)
    else:
        out.append(b*3)
for i in out:
    print(i)
  	 	  	    		    	 	    	  	