def main():
    t = int(input())
    while t is not 0:
        t -= 1
        a, b, c = [int(s) for s in input().split()]
        lim = c // 2
        if b < lim:
            print(3 * b)
        else:
            print(3 * lim + min(a, (b - lim) // 2) * 3)


if __name__ == '__main__':
    main()
