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 <bits/stdc++.h>
using namespace std;

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

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

C++: #include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

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

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

C++: 
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>
#include <sstream>

#define all_range(C) std::begin(C), std::end(C)


int main()
{
	using std::endl;
	using std::cout;
	using std::cin;

	while (true)
	{
		std::string gengou;
		cin >> gengou;
		if (gengou == "#") { break; }

		int y, m, d;
		cin >> y >> m >> d;
		if ((y > 31) || y == 31 && (
			m > 4
			)) {
			gengou = "?";
			y -= 30;
		}
		cout << gengou << ' '
			<< y << ' '
			<< m << ' '
			<< d << '\n';
	}

	return 0;
}
#endif

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
  while (1){
    string g;
    cin >> g;
    if (g == "#"){
      break;
    }
    int y, m, d;
    cin >> y >> m >> d;
    if(y <= 30 || y == 31 && m <= 4){
      cout << g << ' ' << y << ' ' << m << ' ' << d << endl;
    } else {
      cout << '?' << ' ' << y - 30 << ' ' << m << ' ' << d << endl;
    }
  }
}

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

int main(){

    while(1){
        string s; cin >> s;
        if(s == "#") break;
        int y, m, d; cin >> y >> m >> d;
        string ans;
        if(y <= 30) ans = "HEISEI";
        else if(y >= 32){
            ans = "?";
            y -= 30;
        }
        else{
            if(m <= 4) ans = "HEISEI";
            else{
                ans = "?";
                y -= 30;
            }
        }

        cout << ans << " " << y << " " << m << " " << d << endl;
    }
    return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int y,m,d;
string s;
main()
{
    while(cin>>s,s!="#")
    {
        cin>>y>>m>>d;
        if(y>31||y==31&&m>4)y-=30,s="?";
        cout<<s<<" "<<y<<" "<<m<<" "<<d<<endl;
    }
}

C++: #include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}



signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  while(1){
    string str;
    cin>>str;
    if(str == "#") break;
    int y, m, d;
    cin>>y>>m>>d;

    if(y > 31) str = "?", y -= 30;
    else if(y == 31){
      if(m > 4) str = "?", y -= 30;
      else if(m == 4){
	if(d > 30) str = "?", y -= 30;
      }
    }
    cout<<str<<" "<<y<<" "<<m<<" "<<d<<endl;

  }
  return 0;
}