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

#define FOR(i,s,t) for(int i = s ; i < t ; i++)

int main() {

	string s;
	while (cin >> s) {
		if (s == "#")break;
		int y, m, d; cin >> y >> m >> d;
		bool ok = 0;
		if (y < 31 || (y == 31 && m <= 4)) {
			ok = 1;
		}
		else {
			y -= 30;
		}


		if (ok) {
			cout << "HEISEI" << " " << y << " " << m << " " << d << endl;
		}
		else {
			cout << "?" << " " << y << " " << m << " " << d << endl;
		}
	}
}
