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

}

C++: #include <iostream>
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 || (y==31 && m<5)){
            cout << s << " " << y << " " << m << " " << d << endl;
        }else{
            cout << "? " << y-30 << " " << m << " " << d << endl;
        }
    }
    return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <valarray>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <tuple>
#include <random>

using namespace std;
using ll = long long;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  string g;
  int y, m, d;
  while (cin >> g >> y >> m >> d, g != "#")
  {
    if (y < 31)
      cout << g << ' ' << y << ' ' << m << ' ' << d << endl;
    else
    {
      if (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;

#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;
}