#include<iostream>
#include<iostream>
using namespace std;
int main() {
    int n;
    cin>>n;
    bool ok =true;
    for(int i = 0;i<n;i++)
    {
        string type,name;
        cin>>type>>name;
        
        if(type=="Student") {
            int grade;
            if(!(cin>>grade)||grade<1||grade>12) {
                ok=false;
                break;
            }
            cout<<"student:"<<name<<",Grade: "<<grade<<'\n';
        }
        else if (type=="Teacher") {
            string subject;
            if(!(cin>>subject)){
                ok=false;
                break;
            }
            cout<<"Teacher: "<<name<<", SUbject: "<<subject<<'\n'
        }
        else{
            ok=false;
            breal;
        }
        if(!ok)
        {
            cout<<"Invalid input";
        }
    }return 0;
}