482. A2OJ Meaning

Problem Statement:
You can safely skip this paragraph. Many contestants are asking what does A2OJ mean, so I decided to make a problem to explain its meaning. The original domain name for A2OJ was ahmed-aly.com (it's still working and redirects to a2oj.com), and the website was called Ahmed Aly Tools, which was a strange name. Then it became an online judge, not just a website for some tools, but again Ahmed Aly Online Judge looks strange and long. So I decided to make it AAOJ as an acronym, but the domain name wasn't available. So I decided to change AA to A2 and it became A2OJ.

In this problem you are given a long name which consists of one or more words, and your task is to generate an acronym for it. The acronym is simply the concatenation of the first letter of each word in the same order of words. But if there is a continuous group of 2 or more of the same letter next to each other, you remove all of them but keep only one followed by the number of occurrences. For example "ahmed aly online judge" becomes "a2oj".

The number of English letters in your output should be minimal (not counting the digits), which means something like "ab ab ab ab" must be "a4", it can't be "a2a2".

Input Format:
Your program will be tested on one or more test cases. The first line of the input will be a single integer T (1 ≤ T ≤ 100) representing the number of test cases. Followed by T test cases.

Each test case starts with a line containing an integer N (the number of words in the name, 1 ≤ N ≤ 100).

Followed by a line containing N words separated by a space, each word will consist of at least 1 and at most 10 lower case English letters.

Output Format:
For each test case print a single line containing just the acronym of the given name as described above.

Sample Input:
2 4 ahmed aly online judge 6 a a a a b a

Sample Output:
a2oj a4ba

 Added by: ahmed_aly Added at: 2017-10-15 18:00:00 UTC Time Limit: 2 seconds Partial score: No Source: A2OJ Code Battle Round 2