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>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>

#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;


const ll mod = 1000000007;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
// bool debug=false;

/*---------------------------------------------------*/

int main(){
  string x;
  int year, month, day;
  while(cin >> x) {
    if(x == "#") break;
    cin >> year >> month >> day;
    bool is_new = false;
    if(year > 31) {
      is_new = true;
    } else {
      if(year == 31 && month > 4) is_new = true;
    }
    if(is_new) cout << "?" << " " << year - 30 << " " << month << " " << day << endl;
    else cout << "HEISEI" << " " << year << " " << month << " " << day << endl;
  }
  return 0;
}

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

int main(){
    while(true){
        std::string s;
        std::cin>>s;
        if(s=="#")break;
        int y,m,d;
        std::cin>>y>>m>>d;
        if(y>31){s="?";y-=30;}
        else if(y==31&&m>4){s="?";y-=30;}
        std::cout<<s<<" "<<y<<" "<<m<<" "<<d<<std::endl;
    }
    return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<tuple>
#include<utility>
#include<stack>
#include<set>
#include<iomanip>
using namespace std;
using ll=long long int;

int main() {

	string s;

	while (cin >> s, s != "#") {
		int y, m, d;
		cin >> y >> m >> d;

		if (y > 31 || (y == 31 && m >= 5)) {
			s = "?";
			y -= 30;
		}

		cout << s << " " << y << " " << m << " " << d << endl;



	}

	return 0;
}