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: def solve(ip):
    g, y, m, d = ip.split()
    y, m, d = map(int, [y, m, d])
    if (y == 31 and m >= 5) or (y >= 32):
        g = "?"
        y -= 30

    return [g, y, m, d]


def main():
    ans = []
    while True:
        ip = input()
        if (ip[0] == "#"):
            break
        ans.append(solve(ip))
    for i in ans:
        print(*i)


main()

Python: """
a = int(input())
# スペース区切りの整数の入力
b, c = map(int, input().split())
# 文字列の入力
s = input()
# 出力
print(str(a+b+c) + " " + s)
"""


def main():
	while(1):
		N = input().split() 
		if N[0] == "#":
			break
		y = int(N[1])
		m = int(N[2])
		d = int(N[3])
		if y >= 32:
			print("? {} {} {}".format(y-30,m,d))
		if y < 31:
			print("{} {} {} {}".format(N[0],y,m,d))
		if y==31:
			if m>=5:

				print("? {} {} {}".format(y-30,m,d))
			else:
				print("{} {} {} {}".format(N[0],y,m,d))


if __name__ == '__main__':
    main()

Python: import math
while 1:
    a = input().split()
    if a[0] == "#":
        break
    nengo = a[0]
    y = int(a[1])
    m = int(a[2])
    d = int(a[3])
    if y > 31:
        y -= 30
        nengo = "?"
    elif y == 31:
        if m >= 5:
            nengo = "?"
            y = 1
    print(nengo,y,m,d)

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[cnt]>31:
        ls_g[cnt]="?"
    elif ls_y[cnt]==31:
        if ls_m[cnt]>=5:
            ls_g[cnt]="?"
for _ in range(cnt):
    print(ls_g[cnt]+" "+str(ls_y[cnt])+" "+str(ls_m[cnt])+" "+str(ls_d[cnt]))

Python: while 1:
    s = input()
    if s == "#":
        break
    y, m, d = map(int, s.split()[1:])
    if (y, m) >= (31, 5):
        print("? {} {} {}".format(y-30, m, d))
    else:
        print("HEISEI {} {} {}".format(y, m, d))

Python: while True:
    a=list(input().split())
    if(a[0]=="#"):
        break
 
    y=int(a[1])
    m=int(a[2])
    d=int(a[3])
    if(y <= 30):
        print(a[0],y,m,d)
    elif(y == 31 and m<=4):
        print(a[0],y,m,d)
    else:
        n=y-30
        print("?",n,m,d)

Python: while True:
    a = list(map(str, input().split()))
    if a[0] == "0":
        break
    elif int(a[1]) <= 30:
        print(" ".join(a))
    elif int(a[1]) == 31 and int(a[2]) <= 4:
        print(" ".join(a))
    else:
        a[0] = "?"
        s = int(a[1])
        s -= 30
        a[1] = str(s)
        print(" ".join(a))

Python: while True:
    try:
        s,y,m,d=input().split()
    except:
        break
    if int(y)>31 or (int(y)==31 and int(m)>4):
        print("?",str(int(y)-30),m,d)
    else:
        print(s,y,m,d)

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

for i in range(101):
    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: import sys
sys.setrecursionlimit(10**7)

def main(n):
	if n[0] == "#":
		return
	if (int(n[1]) > 31) or (int(n[1]) == 31 and int(n[2]) > 4):
		n[0] = "?"
		n[1] = str(int(n[1]) - 30)
	print(" ".join(n))
	return main(input().split())

main(input().split())

Python: while 1:
    data = input()
    if data == "#":
        break

    _, y, m, d = data.split()
    y = int(y)
    m = int(m)
    d = int(d)

    if y == 31:
        if m <= 4:
            gen = "HEISEI"
        else:
            gen = "?"
            y -= 30
    elif y < 31:
        gen = "HEISEI"
    else:
        gen = "?"
        y -= 30

    print(gen, y, m, d)

Python: # AOJ 2881: Change of the Era Name
# Python3 2018.7.10 bal4u

# y << 9, m << 5, d 
LAST = (31<<9) + (5<<5) + 1		# H31.5.1

while True:
	a = input()
	if a == "#": break
	era, y, m, d = a.split()
	y, m, d = int(y), int(m), int(d)
	date = (y<<9) + (m<<5) + d
	if date >= LAST: print('?', y-30, m, d)
	else: print(era, y, m, d)

Python: while True :
  try :
    g, y, m, d = map(str, input().split())
    y = int(y)
    m = int(m)
    d = int(d)
    if(y <= 30) :
      print('HEISEI', y, m, d)
    elif(y == 31 and m <= 4):
      print('HEISEI',y , m, d)
    else:
      y = y - 30
      print('?', y, m, d)
  except :
      break

Python: while True :
    try :
        g, y, m, d = map(str, input().split())
        y = int(y)
        m = int(m)
        d = int(d)
        if(y <= 30) :
            print("HEISEI", y, m, d)
        elif(y == 31 and m <= 4):
            print("HEISEI",y , m, d)
        else:
            y = y - 30
            print("?", y, m, d)
    except :
        break

Python: ls_g=[]
ls_y=[]
ls_m=[]
ls_d=[]
cnt = 0
while True:
    try:
        g=input()
        y,m,d=map(int,input().split())
        ls_g.append(g)
        ls_y.append(y)
        ls_m.append(m)
        ls_d.append(d)
        cnt += 1
    except:
        break;

for _ in range(cnt):
    if ls_y[cnt]>31:
        ls_g[cnt]="?"
    elif ls_y[cnt]==31:
        if ls_m[cnt]>=5:
            ls_g[cnt]="?"
for _ in range(cnt):
    print(ls_[g]+" "+ls_y[cnt]+" "+ls_m[cnt]+" "+ls_d[cnt])

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

    g = line.split()[0]
    y, m, d = map(int, line.split()[1:])
    if y > 31:
        g = '?'
    elif m > 4:
        g = '?'
    print(g, y, m, d)

Python: while True:
    po = input()
    if po == '#':
        break
    y,m,d = [int(i) for i in po.split()[1:]]
    if y > 31 or (y == 31 and m > 4):
        print(f"? {y-30} {m} {d}")
    else:
        print(f"HEISEI {y} {m} {d}")

Python: 
while 1:
    before_convert = input().split()

    era = before_convert[0]
    
    if era == "#":
        exit()
    
    heisei_year = int(before_convert[1])
    month = int(before_convert[2])
    day = before_convert[3]

    if heisei_year <= 30:
        era = "HEISEI"
        year = heisei_year
    elif heisei_year == 31:
        if month < 5:
            era = "HEISEI"
            year = heisei_year
        else:
            era = "?"
            year = 1
    else:
        era = "?"
        year = heisei_year - 30

    print("{0} {1} {2} {3}".format(era, year, month, day))

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

Python: while True:
    data = input()
    if data == "#": break
    data = data.split()
    y = int(data[1])
    m = int(data[2])
    d = int(data[3])

    if 31 > y or (y == 31 and 4 >= m):
        print("HEISEI {} {} {}".format(y,m,d))
    else:
        new_y = y - 31 + 1
        print("? {} {} {}".format(new_y,m,d))

Python: while True:
    po = input()
    if po == '#':
        break
    y,m,d = [int(i) for i in po.split()[1:]]
    if y > 32 or (y == 31 and m > 4):
        print(f"? {y-30} {m} {d}")
    else:
        print(f"HEISEI {y} {m} {d}")