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

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