import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class p1 {
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		FastReader g = new FastReader();
		int t = g.nextInt();
		for (int p = 0; p < t; p++) {
			int a = g.nextInt();
			int b = g.nextInt();
			int c = g.nextInt();
			int count = 0;
			if (c > b || (a==c&&c==b)) {
				while (b > 0 && c > 1) {
					
					count += 3;
					b -= 1;
					c -= 2;
				}
				while (a > 0 && b > 1) {
					
					count += 3;
					a -= 1;
					b -= 2;
				}
			} else  {
				while (a > 0 && b > 1) {
					count += 3;
					a -= 1;
					b -= 2;
				}
				while (b > 0 && c > 1) {
					count += 3;
					b -= 1;
					c -= 2;
				}
			}
			System.out.println(count);
		}
	}

}
