#include <iostream>
#include <string>

using namespace std;

int main(){
  string g[100];
  int y[100], m[100], d[100];
  int cnt_in = 0;

  for(;;){
    cin >> g[cnt_in];
    if(g[cnt_in] == "#"){
      break;
    }

    cin >> y[cnt_in] >> m[cnt_in] >> d[cnt_in];
    cnt_in++;
  }

  for(int i = 0; i < cnt_in; i++){
    if((y[i] > 31) || (y[i] == 31) && (m[i] >= 5)){
      cout << "?" << " " << y[i] - 30 << " " << m[i] << " " << d[i] << endl;
    }
    else{
      cout << g[i] << " " << y[i] << " " << m[i] << " " << d[i] << endl;
    }
  }

  return 0;
}

