#include<iostream>
using namespace std;

int main(){
    int n;
    cin>>n;
    if (n<1||n>10){
        return 0;
    }
    string type, name , sunject;
    int grade;
    bool valid = true;
    
    for (int i=0; i<n; i++){
        cin>>type>>name;
        if (type == "Student"){
            cin>>grade;
            if (grade<1||grade>12)valid=false;
            if (valid) cout<< "Student:"<<name<<".Grade:"<<grade<<endl;
        }
        else if (type == "Teacher"){
            cin>>subject;
            cout<<"Teacher: "<<name<<". Subject: "<<subject<<endl;
        }
        else valid = false;
    }
    if (!valid) cout<<"invalid input";
    return 0
}