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

void solve(int a, int b, int c){
	if(a <= 30){
		cout << "HEISEI " << a << " " << b << " " << c << "\n";
	}else if(a == 31){
		if(b <= 4){
			cout << "HEISEI " << a << " " << b << " " << c << "\n";
		}else{
			cout << "? " << 1 << " " << b << " " << c << "\n";
		}
	}else{
		cout << "? " << a-30 << " " << b << " " << c << "\n";
	}
}

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	while(1){
		string s;
		cin >> s;
		if(s == "#") return 0;
		int a, b, c;
		cin >> a >> b >> c;
		solve(a, b, c);
	}
}
