import static java.lang.System.err; public class Main { public static void main(String[] args) { java.io.PrintWriter out = new java.io.PrintWriter(System.out); new Main(out); out.flush(); err.flush(); } public Main(java.io.PrintWriter out) { try (java.util.Scanner sc = new java.util.Scanner(System.in)) { int T = sc.nextInt(); while(T --> 0) { long A = sc.nextLong(), B = sc.nextLong(), C = sc.nextLong(); long ans = Math.min(A, C) * 2; A -= ans / 2; C -= ans / 2; ans += C / 2; ans += B / 2 * 2; B %= 2; ans += Math.min(A, B); out.println(ans); } } } }