#include <bits/stdc++.h>

using namespace std;

int main(){
    string s;
    int y,m,d;
    while(true) {
        cin >> s >> y >> m >> d;
        if (s == "#") break;
        if(y == 31 && m >= 5) cout << "? " << y - 30 << " " << m << " " << d << endl;
        else if( y >= 32) cout << "? " << y - 30 << " " << m << " " << d << endl;
        else cout << s << " " << y << " " << m << " " << d << endl;
    }
}
