from math import floor, ceil

t = int(input())

for _ in range(t):
    a, b, c = map(int, input().split())

    ans = 0

    ans += min(floor(c/2), b)*3

    b -= min(floor(c/2), b)

    ans += min(floor(b/2), a)*3

    print(ans)