//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
 
 
#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000
 
using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;
 
int dy[5] = { 0,0,1,-1,0 };
int dx[5] = { 1,-1,0,0,0 };
 
int main(void){

	while(1){
		string g;
		int y,m,d;

		cin>>g;
		if(g=="#"){
			break;
		}
		cin>>y>>m>>d;

		if(y<=30){
			cout<<g<<" "<<y<<" "<<m<<" "<<d<<endl;
		}else if(y==31){
			if(m<=4){
				cout<<g<<" "<<y<<" "<<m<<" "<<d<<endl;
			}else{
				cout<<"?"<<" "<<y-30<<" "<<m<<" "<<d<<endl;
			}
		}else{
			cout<<"?"<<" "<<y-30<<" "<<m<<" "<<d<<endl;
		}

	}

}
