for i in range(1, 11):
n, pw = map(int, input().split())
pw = str(pw)
stack = [pw[0]]
for j in range(1, len(pw)):
# 스택이 비어있지 않고, 제일 위 원소가 현재 원소가 같으면 pop()
if len(stack) and stack[-1] == pw[j]:
stack.pop()
else:
stack.append(pw[j])
print(f"#{i} {int(''.join(stack))}")