#include "bits/stdc++.h"

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
ll inf = 1e18;

ll y, m, d;
string g;

int main(){
	while(cin >> g && g != "#"){
		cin >> y >> m >> d;
		ll ymd =  10000 * y + 100 * m + d;
		if(ymd >= 310501){
			g = "?";
			y -= 30;
		}
		cout << g << " " << y << " " << m << " "<< d << endl;
	}

	return 0;
}
