#!/usr/bin/env python

import codecs
import sys
import unicodedata

def is_whitespace(char):
    return unicodedata.category(char) in ('Zs', 'Zl', 'Zp', 'Cc')

def ends_sentence(char):
    return char in '.?!'

in_word = False
in_sentence = False

for line in codecs.getreader('UTF-8')(sys.stdin):
    for char in line:
        if is_whitespace(char):
            tag = 'O'
            in_word = False
        elif ends_sentence(char):
            tag = 'T'
            in_sentence = False
            in_word = False
        else:
            if in_word:
                tag = 'I'
            elif in_sentence:
                tag = 'T'
                in_word = True
            else:
                tag = 'S'
                in_sentence = True
                in_word = True
        print '%d %s' % (ord(char), tag)

print
