from sys import stdin

input = raw_input
range = xrange

for _ in range(int(input())):
    a, b, c = map(int, input().split())
    mi = min(c // 2, b)
    ans = mi * 3
    b -= mi
    ans += min(b // 2, a) * 3
    print(ans)
