#include <iostream>
#include <algorithm>

using namespace std;

int solve(){
  string g;
  int y, m ,d;

  cin >> g >> y >> m >> d;

  if(g == "#") return 0;
  
  if(y >= 32 || (y == 31 && m >= 5)){
    g = "?";
    y -= 30;
  }
  
  cout << g << " " << y << " " << m << " " << d << endl;
  return 1;
}

int main(){
  while(solve());
}

