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 <iostream>
#include <utility>
#include <string>

using namespace std;

string s;
int y, m, d;

int main(void)
{
	while(1){
		cin >> s;
		if(s == "#") break;
		cin >> y >> m >> d;
		
		if(make_pair(y, make_pair(m, d)) > make_pair(31, make_pair(4, 30))){
			s = "?", y -= 30;
		}
		cout << s << " " << y << " " << m << " " << d << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

int main() {
    while (1) {
        string g;
        int y, m, d;
        cin >> g;
        cin >> y >> m >> d;
        if(g == "#")break;
        if(y<31 || y==31 && m<5){
            cout << g << " " << y << " " << m << " " << d << endl;
        }
        else {
            cout << "?" << " " << y-30 << " " << m << " " << d << endl;
        }
    }

    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  while (true) {
    string g;
    cin >> g;
    if (g == "#") return 0;
    
    int y, m, d;
    cin >> y >> m >> d;
    if (y >= 32 || (y == 31 && m >= 5)) {
      cout << "? " << y - 30 << " " << m << " " << d << '\n';
    }
    else {
      cout << g << " " << y << " " << m << " " << d << '\n';
    }
  }
}

C++: #include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl '\n'
int mod=1e9+7;
int mod2=998244353;

signed main(){
  while(true){
    string g;
    cin>>g;
    if(g=="#")break;
    int y,m,d;
    cin>>y>>m>>d;
    if(y<=30||(y==31&&m<4)||(y==31&&m==4&&d<=30))cout<<g<<" "<<y<<" "<<m<<" "<<d<<endl;
    else cout<<"? "<<y-30<<" "<<m<<" "<<d<<endl;
  }
}

C++: #include<iostream>
#include<string>

using namespace std;

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

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

int main() {
    string g;
    while (cin >> g, g != "#") {
        int y, m, d; cin >> y >> m >> d;
        if (y > 31 || (y == 31 && m >= 5)) {
            g = "?";
            y = y - 30;
        }
        cout << g << " " << y << " " << m << " " << d << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <unordered_map>
#define Debug 0
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 998244353;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

//最大公約数
template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//最小公倍数
template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

//入出力高速化(非同期化)
void fast_input() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

void solve() {
    int y, m, d;
    cin >> y >> m >> d;
    if (y <= 31 && m < 5) {
        cout << "HEISEI";
        cout << " ";
        cout << y;
        cout << " ";
        cout << m;
        cout << " ";
        cout << d;
        cout << endl;
    } else {
        cout << "?";
        cout << " ";
        cout << y-30;
        cout << " ";
        cout << m;
        cout << " ";
        cout << d;
        cout << endl;
    }
}

int main(){
    vector<string> ans;
    while (1) {
        string nengo;
        cin >> nengo;
        if (nengo == "HEISEI") solve();
        else break;
    }
}

C++: /*  -*- coding: utf-8 -*-
 *
 * 2881.cc: Change of the Era Name
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

char sd[16];

/* subroutines */

/* main */

int main() {
  while (scanf("%s", sd) == 1 && sd[0] != '#') {
    int y, m, d;
    scanf("%d%d%d", &y, &m, &d);

    if (y > 31 || (y == 31 && m >= 5))
      printf("? %d %d %d\n", y - 31 + 1, m, d);
    else
      printf("HEISEI %d %d %d\n", y, m, d);
  }
  return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

int main()
{
	string g;
	int y, m, d;
	while (cin >> g, g != "#")
	{
		cin >> y >> m >> d;
		if (y <= 30)
		{
			printf("HEISEI %d %d %d\n", y, m, d);
		}
		else if (y == 31)
		{
			if (m < 5)
				printf("HEISEI %d %d %d\n", y, m, d);
			else
				printf("? 1 %d %d\n", m, d);
		}
		else
		{
			printf("? %d %d %d\n", y - 30, m, d);
		}
	}
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
using namespace std;
#define Would
#define you


int main() {
	string h;
	while (1) {
		cin >> h;
		if (h == "#") { break; }
		int a, b, c;
		cin >> a >> b >> c;
		if (a >= 31) {
			cout << "?" << " ";
			a -= 30;
		}
		else { cout << "HEISEI" << " "; }
		cout << a << " " << b << " " << c << endl;
	}
}