Go: package main

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

func main() {
	const S = "HEISEI"
	io := NewIo()
	defer io.Flush()
	for io.Next() == S {
		y, m, d := io.NextInt(), io.NextInt(), io.NextInt()
		if y > 31 || y == 31 && m > 4 {
			io.Println("?", y-30, m, d)
		} else {
			io.Println(S, y, m, d)
		}
	}
}

// I/O template
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buff []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buff = append(buff, line...)
		if !isPrefix {
			break
		}
	}
	return string(buff)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	s := io.tokens[io.nextToken]
	io.nextToken++
	return s
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntSlice(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func (io *Io) PrintStringSlice(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func ExampleIo() {
	io := NewIo()
	defer io.Flush()
	a := make([]int, 0, 3)
	a[0], a[1], a[2] = io.NextInt(), io.NextInt(), io.NextInt()
	io.Println(a)
	io.PrintIntSlice(a)
	Log("io", a)
}

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}")