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

C++: #include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <locale>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
#include <map>

using namespace std;

int solve(){
    int year,month, day;
    vector<string> reiwa;
    cin>>year>>month>>day;
    if(year > 31){
        // reiwa.push_back("?");
        // reiwa.push_back(sprintf(year-30));
        cout<<"? "<<year-30<< " "<<month<<" "<<day<<endl;
            return 0;
    }else if(year == 31){
        if(month >= 5){
            // reiwa.push_back("?");
            // string s = (string)(year-30);
            // reiwa.push_back(sprintf(year-30));
            cout<<"? "<<year-30<< " "<<month<<" "<<day<<endl;
            return 0;
        }
        else {
            // reiwa.push_back("HEISEI");
            // reiwa.push_back(sprintf(year));
            cout<<"HEISEI "<<year<< " "<<month<<" "<<day<<endl;
            return 0;
        }
    }else{
        //  reiwa.push_back("HEISEI");
        //  reiwa.push_back(sprintf(year));
        cout<<"HEISEI "<<year<< " "<<month<<" "<<day<<endl;
        return 0;
    }
    // reiwa.push_back(sprintf(month));
    // reiwa.push_back(sprintf(day));
    // return reiwa;
}

int main(){
    string heisei;
    vector<vector<string>> ans;
    while(1){
        cin>>heisei;
        if(heisei == "#")break;
        // ans.push_back(solve());
        solve();
    }

    // for(int i = 0;i < ans.size(); i++){
    //     cout<<ans[i][0] << " "<<ans[i][1] << " "<<ans[i][2] <<" "<<ans[i][3]<<endl;
    // }
}

C++: #define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())




int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);


	string s;
	int y, m, d;
	while (cin >> s >> y >> m >> d) {
		if (y>31 || y == 31 && m >= 5) {
			cout << "? ";
			cout << y-30 << ' ' << m << ' ' << d << endl;
		}
		else {
			cout << "HEISEI ";
			cout << y << ' ' << m << ' ' << d << endl;
		}
		
	}



	return 0;
}