import re

mp = {
    '1': 2,
    '2': 5,
    '3': 5,
    '4': 4,
    '5': 5,
    '6': 6,
    '7': 3,
    '8': 7,
    '9': 6,
    '0': 6,
    '+': 2,
    '-': 1
}

mt = re.compile("[+-][0-9]*")

if __name__ == '__main__':

    T = int(input())
    while T:
        T -= 1
        n = int(input())
        e = "+" + input()
        cnt = -2
        for ch in e:
            cnt += mp[ch]
        exps = mt.findall(e)
        for idx, ex in enumerate(exps):
            exps[idx] = '-' + '1' * (len(ex) - 1)
        print(exps)
        cnt += 1
        for ex in exps:
            for ch in ex:
                cnt -= mp[ch]
        print(cnt)