Being a judge is not always an interesting job! For example, it is very boring to wait for the first submission in the contest. So, judges used to entertain themselves using the “I’m Bored” tab in the PC2 software. In this tab, a button is shown and you need to click it (if you can!).

Since Alaa has been a judge in many contests, the “I’m Bored” tab is also boring to her, so, she decided to play a new game in today’s contest. Alaa brings with her a huge bag full of lowercase English letters, and she starts playing with them. Alaa goal is to build a list of palindrome strings of the same length such that each string does not contain the same character more than two times.

After 3 minutes of playing, Alaa wondered what is the longest string’s length that she can build? And what is the maximum number of strings the list can contain? When Alaa brings her notebook to calculate the answers, she starts receiving dozens of submissions. So, she gives you her bag and asks you to find the answers for her. Can you?
Input

The first line contains an integer T (1 ≤ T ≤ 10^4) specifying the number of test cases.

Each test cases consists of a line containing 26 integers f1, …, f26 (0 ≤ fi ≤ 10^9), in which fi is how many letters i Alaa has. The letters are numbered from 1 to 26 starting from ‘a’.
Output

For each test case, print a single line containing two integers x and y, in which x is the length of the strings in the group and y is the size of the group.
Example
Input

2
2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Output

4 1
4 2

Note

A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward as forward, such as “madam” or “racecar”.

题意:给定一个26个字母的个数,要求能组成最长回文串的长度,与最长长度的个数,回文串中每种字母最多选两个

#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int num[27];
bool cmp(int a,int b){
	return a>b;
}
int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		for(int i=0;i<26;i++){
			scanf("%d",&num[i]);
		}
		sort(num,num+26,cmp);
		int len=0,a=0,b=0;//a是能凑对的最小对数,b是1个的个数
		for(int i=0;i<26;i++){
			if(num[i]>=2) {
				len+=2;
				a=num[i]/2;
			}
			else{
				if(num[i]==1) len++;
				break;
			}
		}
		int ans;
		if(len%2==0) ans=a;//如果最大长度是偶数,必然都是由对凑出来的,数目就等于能凑对的最小对数
		else{
			for(int i=0;i<26;i++){
				if(num[i]==1) b++;
			}
			if(a>0) ans=min(a,b);
			else ans=b;//如果a==0,有几个1个的,数目就有多少
		}
		printf("%d %d\n",len,ans);
	}
	return 0;
}