t = input()
for _ in xrange(t):
    a, b, c = map(int, raw_input().strip().split())
    z = c / 2
    ans = 0
    for x in xrange(a + 1):
        for y in xrange(z + 1):
            if 2 * x + y > b: break
            ans = max(ans, 3 * (x + y))
    print ans