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

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

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

Python: datum = []
while True:
    datum.append(input().split())
    if datum[-1][0]=='#':
        break
datum=datum[:-1]
ans = []
for data in datum:
    if int(data[1]) >= 31 or (int(data[1]) >= 31 and int(data[2]) >= 5):
        ans.append(['?', str(int(data[1])-30), str(data[2]), str(data[3])])
    else:
        ans.append(data)
ans2 = []
for a in ans:
    ans2.append(' '.join(a))
print('\n'.join(ans2))

Python: import sys


def solve(g,  y,  m,  d):
    y = int(y)
    m = int(m)
    d = int(d)

    if y == 31 and m >= 5:
        print('?', y-30, m, d)
    elif y >= 32:
        print('?', y-30, m, d)
    else:
        print(g, y, m, d)


while True:
    s = input()
    if s == "#":
        break
    solve(*map(str,  s.split()))

Python: while True:
    a = list(map(str, input().split()))
    if a[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:
    a = input()
    if(a == "#"):
        break
    g,y,m,d = map(lambda x:x,a.split(" "))
    if(int(y) <=30):
        print(g,y,m,d)
    elif(int(y) <= 31 and int(m) <= 4 and int(d) <= 30):
        print(g,y,m,d)
    else:
        print("?",int(y)-30,m,d)

Python: # 31年5月以降が与えられたら-30する
while 1:
    day_string = str(input())
    if day_string[0] == '#':
        exit()

    g, y, m, d = day_string.split()

    if int(y) > 31 or (int(y) == 31 and int(m) >= 5):
        print(f'? {int(y)-30} {m} {d}')
    else:
        print(f'{g} {y} {m} {d}')

Python: def get_four_data():
    four_data = input().split()
    return four_data

def change_era_name(four_data):
    era, year, month, day = four_data
    year = int(year)
    month = int(month)
    if year >31 or (year >= 31 and month >= 5):
        era = "?"
        year -= 30
    return era, year, month, day

if __name__ == "__main__":
    while True:
        four_data = get_four_data()
        if four_data[0] == "#":
            break
        era, year, month, day = change_era_name(four_data)
        print(era, year, month, day)

Python: def main():
    while True:
        buf = input().split()
        if buf[0] == "#":
            return
        g = buf[0]
        y,m,d = map(int,buf[1::])
        y = int(y)
        m = int(m)
        d = int(d)
        if y > 31 or (y == 31 and m >= 5):
            g = "?"
            y -= 30
        print(g,y,m,d)

if __name__ == '__main__':
    main()

Python: while True:
    s = input()
    if s == "#":
        break
    g, y, m, d = s.split()
    if int(y) >= 32:
        g = "?"
        y = str(int(y)-30)
    elif int(y) == 31:
        if int(m) >= 5:
            g = "?"
            y = str(int(y)-30)
    print(g, y, m, d)