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

int main(){
  while(true){
    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)cout<<(m<=4?g:"?")<<" "<<(m<=4?y:y-30)<<" "<<m<<" "<<d<<endl;
    else  cout<<"? "<<y-30<<" "<<m<<" "<<d<<endl;
  }
  return 0;
}

