How to properly do out-of-sample prediction for hierarchical model

I’m more confused than ever. How should I write the prediction model if I want to predict on 1 of the previous groups and 2 new groups?