#include<bits/stdc++.h>

#define fi first
#define se second
#define show(x) cerr << #x << "=" << "\n"
typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  FILE *stream2;
  stream1 = freopen("in.txt", "r", stdin);
  stream2 = freopen("out.txt", "w", stdout);
  if (stream1 == NULL) return 0;
  if (stream2 == NULL) return 0;
#endif
  string s;
  while (cin >> s) {
    if (s == "#") break;
    int a, b, c; cin >> a >> b >> c;
    pair<pair<int,int> ,int> p = make_pair(make_pair(a, b), c);
    pair<pair<int,int> ,int> q = make_pair(make_pair(31, 4), 30);
    if (p > q) {
      cout << "? " << a - 30 << " " << b << " " << c << endl;
    } else {
      cout << "HEISEI " << a << " " << b << " " << c << endl;
    }
  }
#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
  fclose(stream1);
  fclose(stream2);
#endif
  return 0;
}
