#include<bits/stdc++.h>
using namespace std;
#define INF (1LL<<30)
#define DEKAI 1000000007
#define lp(i,n) for(int i=0;i<n;i++)
#define int long long

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