t = int(input())
for i in range(t):
    q = input().split()
    a = int(q[0])
    b = int(q[1])
    c = int(q[2])
    ans = min(c // 2, b) * 3
    b -= min(c // 2, b)
    ans += min(b // 2, a) * 3
    print(ans)
