#-*- coding: utf-8 -*-

# int(input())
# [int(inp) for inp in input().split()]

t = int(input())

for t_ in range(t):
    a, b, c = [int(inp) for inp in input().split()]

    first = min(c // 2, b)
    print(3 * (first + min((b - first) // 2, a)))