t = int(raw_input())
for _ in xrange(t):
    a, b, c = map(int, raw_input().split())
    ans = 0
    x = min(b, c // 2)
    ans += 3 * x
    b -= x
    y = min(a, b // 2)
    ans += 3 * y
    print ans
