using System; using System.Collections.Generic; using System.Linq; class Program { static void Main(string[] args) { var T = int.Parse(Console.ReadLine()); var ans = 0L; for (int i = 0; i < T; i++) { var input = Console.ReadLine().Split().Select(long.Parse).ToArray(); var A = input[0]; var B = input[1]; var C = input[2]; var min = Math.Min(A, C); ans += 2 * min; A -= min; C -= min; var quo = B / 2; ans += 2 * quo; B -= 2 * quo; if (B == 1) if (A >= 1) { B--; A--; ans++; } else if (C >= 1) { B--; C--; } if (C > 0) ans += C / 2; Console.WriteLine(ans.ToString()); ans = 0; } } }