题目描述: 三个同样的字母连在一起,一定是拼写错误,去掉一个的就好啦:比如 helllo -> hello
;两对一样的字母(AABB型)连在一起,一定是拼写错误,去掉第二对的一个字母就好啦:比如 helloo -> hello;上面的规则优先“从左到右”匹配,即如果是AABBCC,虽然AABB和BBCC都是错误拼写,应该优先考虑修复AABB,结果为AABCC

第一行包括一个数字N,表示本次用例包括多少个待校验的字符串。
后面跟随N行,每行为一个待校验的字符串。

输出描述:
N行,每行包括一个被修复后的字符串。

示例1
2
helloo
wooooooow

输出
hello
woow

def zfc(a):
    res=[]
    for i in a:
        if len(res)<2:
            res.append(i)
            continue
        if len(res)>=2:
            if i==res[-1] and i==res[-2]:
                continue
        if len(res)>=3:
            if i==res[-1] and res[-3]==res[-2]:
                continue
        res.append(i)
    a="".join(res)
    return a
n=eval(input())
for i in range(n):
    a=input()
    print(zfc(a))