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

int main() {
  string g;
  int y, m, d;
  while (true) {
    cin >> g >> y >> m >> d;
    if (g == "#") break;

    if (31 <= y) {
      if (y == 31) {
        if (m >= 5 && d >= 1) {
          cout << "? " << y - 30 << " " << m << " " << d;
        } else {
          cout << g << " " << y << " " << m << " " << d;
        }
      } else {
        cout << "? " << y - 30 << " " << m << " " << d;
      }
    } else {
      cout << g << " " << y << " " << m << " " << d;
    }

    cout << "\n";
  }

  return 0;
}
