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

Python: reiwa="?"
while True:
    data=input().split()
    g=data[0]
    if g == "#":
        break
    else:
        y=int(data[1])
        m=int(data[2])
        d=int(data[3])
    
    #平成
    if y<31 or (y==31 and m<5):
        print(f"{g} {y} {m} {d}")
    #新元号
    else:
        y=y-30
        print(f"{reiwa} {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[_]>31:
        ls_g[_]="?"
        ls_y[_]-=30
    elif ls_y[_]==31 and ls_m[_]>=5:
        ls_g[_]="?"
        ls_y[_]-=30
for i in range(cnt):
    print(ls_g[i]+" "+str(ls_y[i])+" "+str(ls_m[i])+" "+str(ls_d[i]))

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

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    string s;
    while(cin >> s, s != "#"){
        int y, m, d;
        cin >> y >> m >> d;
        if(y > 31 || (y == 31 && m >= 5)){
            printf("? %d %d %d\n", y-30, m, d);
        }else {
            printf("HEISEI %d %d %d\n", y, m, d);
        }
    }
    return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;

int main()  {
  string g;
  int y, m, d;

  while (cin >> g, g != "#") {
    cin >> y >> m >> d;
    if (y > 30 && m != 4)
      cout << "? " << y-30 << ' ' << m << ' ' << d << endl;
    else
      cout << g << ' ' << y << ' ' << m << ' ' << d << endl;
  }
  return 0;
}

C++: #include<iostream>
using namespace std;

int main(){
    string g;
    int y,m,d;
    int ans;

    while(1){
        cin>>g>>y>>m>>d;
        if(g=="#")break;

        if(y>=32||(y==31&&m>=5))cout<<"? "<<y-30<<" "<<m<<" "<<d<<endl;
        else cout<<g<<" "<<y<<" "<<m<<" "<<d<<endl;
    }

    return 0;
}

C++: #include <cstdio>
#include <string>
#include <vector>
#include <algorithm>

int testcase_ends() {
  char buf[8];
  scanf("%s", buf);
  std::string s = buf;
  if (s == "#") return 1;

  std::vector<int> a(3), b{31, 5, 1};
  for (auto& ai: a) scanf("%d", &ai);

  if (a < b) {
    printf("HEISEI %d %d %d\n", a[0], a[1], a[2]);
  } else {
    printf("? %d %d %d\n", a[0]-30, a[1], a[2]);
  }
  return 0;
}

int main() {
  while (!testcase_ends()) {}
}