#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)











int main(){
    string g;
    int y, m, d;
    while(cin >> g, g != "#"){
        cin >> y >> m >> d;
        if(y < 31){
            cout << "HEISEI " << y << " " << m << " " << d << endl;
        }
        else if(y > 31){
            cout << "? " << y - 30 << " " << m << " " << d << endl; 
        }
        else{
            if(m < 5){
                cout << "HEISEI " << y << " " << m << " " << d << endl;
            }
            else{
                cout << "? " << y - 30 << " " << m << " " << d << endl;
            }
        }
    }
}
