for _ in range(int(input())): s = input() n = s[11:-5] print(s.replace(n, str(int(n) + 1)))