B. Palindrome

B. Palindrome

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

Time Limit: 1.0 s

Memory Limit: 256.0 MB

Description

You are given three positive integers n, m, and k, which represent the exact number of characters 0, 1, and 2 available, respectively. You want to construct the longest possible palindrome string S using at most n zeros, m ones, and k twos. Compute and print the maximum possible length of such a palindrome. A palindromic string reads the same forward and backward. Few examples of such palindromes - 0, 1, 2, 11, 00, 101, 121 etc.

Input

  • The first line contains a single integer T(1 ≤ T ≤ \(10^5\)), the number of test cases.
  • Each of the next T lines contains three space-separated integers n, m, k.(1 ≤ n, m, k ≤ \(10^9\))

Output

  • For each test: Print the length of longest palindrome string S you have made.

Sample

Input Output
3
1 2 4
10 2 5
12 12 12
7
17
36

First test case :
String S="2120212", is a palindromic string. Where at most n=1 zero, m=2 ones and k=4 twos.
The length of the string S is 7 which is maximum.

Brain Booster #10

Not Attended
Status
Done
Rule
ACM/ICPC
Problem
6
Start at
2025-06-13 15:30
End at
2025-06-13 18:00
Duration
2.5 hour(s)
Host
Partic.
91