Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

//ConvReiwa ..
func ConvReiwa(sd []string) []string {
	var ne []string
	yr, _ := strconv.Atoi(sd[1])
	mn, _ := strconv.Atoi(sd[2])

	switch {
	case yr < 31:
		return sd
	case yr == 31 && mn < 5:
		return sd
	default:
		ne = append(ne, "?")
		ne = append(ne, strconv.Itoa(yr-30))
		ne = append(ne, sd[2])
		ne = append(ne, sd[3])
		return ne
	}
}

func main() {

	for sc.Scan() {

		str := sc.Text()

		if str == "#" {
			break
		}

		sdt := strings.Split(str, " ")
		ans := ConvReiwa(sdt)

		fmt.Printf("%s %s %s %s\n", ans[0], ans[1], ans[2], ans[3])
	}

}

Python: while True:
    input_data = input()
    if input_data == "#":
        break
    g, y, m, d = input_data.split()
    y = int(y)
    m = int(m)
    d = int(d)
    if y < 31 or (y == 31 and m <= 4):
        print(g, y, m, d)
    else:
        print("?", str(y - 30), str(m), str(d))

Python: import sys
input = sys.stdin.readline

def main():
    while True:
        tmp = input().strip()
        if tmp[0] == "#":
            break
        g, y, m, d = tmp.split()
        y = int(y)
        m = int(m)
        d = int(d)
        if y < 31:
            print(tmp)
        elif y == 31:
            if m <= 4:
                print(tmp)
            else:
                print("?", y-30, m, d)
        else:
            print("?", y-30, m, d)

if __name__ == "__main__":
    main()

Python: while True:
    line = input()
    if line == '#':
        exit()

    g = line.split()[0]
    y, m, d = map(int, line.split()[1:])
    if y > 31 or y >= 31 and m >= 5:
        g = '?'
        y -= 30
    print(g, y, m, d)

Python: answer = []

while True :
    s = input().split()
    
    if s[0] == "#" :
        break
    else :
        if (int(s[1]) > 31) or (int(s[1]) == 31 and int(s[2]) >= 5) : 
            answer.append("?" + " " + str(int(s[1]) - 30) + " " + s[2] + " " + s[3])
        else :
            answer.append(" ".join(s))
            
for a in answer :
    print(a)

Python: # 31年5月1日以降なら年号をマイナス60する
for _ in range(102):
    input_str = str(input())
    if (input_str[0] == '#'):
        exit()
    today = input_str.split()
    if int(today[1]) > 31:
        print(f'? {int(today[1])-30} {int(today[2])} {today[3]}')
        continue

    if int(today[1]) == 31 and int(today[2]) >= 5:
        print(f'? {int(today[1])-30} {int(today[2])} {today[3]}')
        continue
    print(' '.join(today))

Python: while 1:
    s=list(map(str,input().split()))
    if s[0]=="#":break
    if int(s[1])==31 and int(s[2])>=5 or int(s[1])>=32:
        s[0]="?"
        s[1]=str(int(s[1])-30)
    print(' '.join(map(str, s)))

Python: ls_g=[]
ls_y=[]
ls_m=[]
ls_d=[]
cnt = -1
while True:
    try:
        ls=input().split()
        ls_g.append(ls[0])
        ls_y.append(int(ls[1]))
        ls_m.append(int(ls[2]))
        ls_d.append(int(ls[3]))
        cnt += 1
    except:
        break;

for _ in range(cnt):
    if ls_y[_]>31:
        ls_g[_]="?"
        ls_y[_]-=30
    elif ls_y[_]==31 and ls_m[_]>=5:
        ls_g[_]="?"
        ls_y[_]-=30
for i in range(cnt+1):
    print(ls_g[i]+" "+str(ls_y[i])+" "+str(ls_m[i])+" "+str(ls_d[i]))

Python: ans = []

while True:
    a = list(input().split())
    if a[0] == "#":
        break
    a[1], a[2], a[3] = int(a[1]), int(a[2]), int(a[3])
    if a[1] > 31:
        ans.append(["?", a[1] - 30, a[2], a[3]])
    
    elif a[1] == 31:    
        if a[2] >= 5:
            ans.append(["?", 1, a[2], a[3]])
        else:
            ans.append([a[0], a[1], a[2], a[3]])

    else:
        ans.append([a[0], a[1], a[2], a[3]])


for i in ans:
    print("{} {} {} {}".format(i[0], i[1], i[2], i[3]))

Python: ls_g=[]
ls_y=[]
ls_m=[]
ls_d=[]
cnt = -1
while True:
    try:
        ls=input().split()
        ls_g.append(ls[0])
        ls_y.append(int(ls[1]))
        ls_m.append(int(ls[2]))
        ls_d.append(int(ls[3]))
        cnt += 1
    except:
        break;

for _ in range(cnt):
    if ls_y[_]>31:
        ls_g[_]="?"
        ls_y[_]-=30
    elif ls_y[_]==31 and ls_m[_]>=5:
        ls_g[_]="?"
        ls_y[_]-=30
for i in range(cnt+1):
    print(ls_g[i]+" "+str(ls_y[i])+" "+str(ls_m[i])+" "+str(ls_d[i]))

Python: ls_g=[]
ls_y=[]
ls_m=[]
ls_d=[]
cnt = -1
while True:
    try:
        ls=input().split()
        ls_g.append(ls[0])
        ls_y.append(int(ls[1]))
        ls_m.append(int(ls[2]))
        ls_d.append(int(ls[3]))
        cnt += 1
    except:
        break;

for _ in range(cnt+1):
    if ls_y[_]>31:
        ls_g[_]="?"
        ls_y[_]-=30
    elif ls_y[_]==31 and ls_m[_]>=5:
        ls_g[_]="?"
        ls_y[_]-=30
for i in range(cnt+1):
    print(ls_g[i]+" "+str(ls_y[i])+" "+str(ls_m[i])+" "+str(ls_d[i]))

Python: ans = []
while True:
    data = input().split()
    g = data[0]
    if g == '#':
        break
    y, m, d = map(int, data[1:])
    if y > 30 and m > 4:
        ans.append(("? %d %d %d") % (y-30, m, d))
    elif y > 31:
        ans.append(("? %d %d %d") % (y-30, m, d))
    else:
        ans.append(("%s %d %d %d") % (g, y, m, d))
print(*ans, sep="\n")

Python: while True:
    s = input()
    if s == "#": break
    g, y, m, d = s.split()

    if (int(y) == 31 and int(m) > 4) or int(y) > 31:
        print("?", int(y)-30, m, d)
    else:
        print(g, y, m, d)

Python: g=[]
y=[]
m=[]
d=[]

for i in range(100):
    a=input()
    if a=="#":
        break
    else:
        g1,y1,m1,d1=map(str,a.split())
        g.append(g1)
        y.append(int(y1))
        m.append(int(m1))
        d.append(int(d1))

for i in range(len(g)):
    if y[i]>32:
        g[i]="?"
        y[i]=y[i]-30
    if (y[i]==31)*(m[i]>4):
        g[i]="?"
        y[i]=y[i]-30
    print(g[i],y[i],m[i],d[i])

Python: while True:
  s = input()
  if s=="#":
    break

  g, y, m, d = s.split()
  y, m, d = int(y), int(m), int(d)
  if y>=32 or (y==31 and m>=5):
    g = "?"
    y -= 30
  print(g, y, m, d)

Python: while 1:
    s = input()
    if s=='#':
        break
    g, y, m, d=s.split()
    y=int(y)
    m=int(m)
    if y > 31:
        print('? ' + str(y-30) + ' ' + str(m) + ' ' + d)
    elif y == 31:
        if m > 4:
            print('? 1 ' + str(m) + ' ' + d)
        else:
            print('HEISEI 31 ' + str(m) + ' ' + d)
    else:
        print(s)

Python: while True:
    store = input().split()
    g = store[0]
    if g == '#':
        break
    y,m,d = map(int,store[1:])
    if y > 31 or (y == 31 and m > 4):
        print('? %d %d %d' % (y-30,m,d))
    else:
        print('HEISEI %d %d %d' % (y,m,d))

Python: while True:
  l=list(map(str,input().split()))
  if l[0]=="#":
    break
  #print(l)
  y=int(l[1])
  m=int(l[2])
  d=int(l[3])
  if y>=31 and m>=5:
    l[0]="?"
    y=y-30
  elif y>=32:
    l[0]="?"
    y=y-30
  print(l[0],y,m,d)

Python: import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    def f(s):
        g, y, m, d = s.split()
        y = int(y)
        m = int(m)
        d = int(d)
        if (y,m,d) >= (31, 5, 1):
            g = '?'
            y = y - 30
        return '{} {} {} {}'.format(g,y,m,d)

    while 1:
        s = S()
        if s == '#':
            break
        rr.append(f(s))

    return '\n'.join(map(str, rr))


print(main())