Tag Archives: SGU304

SGU 304 解题报告


302. BHTML 1.0

Time limit per test: 2 second(s)
Memory limit: 65536 kilobytes

The hypertext markup language BHTML 1.0 has only two paired tags. They are <UP> </UP> and <DOWN> </DOWN>. The <UP> </UP> tag capitalizes all letters inside its body (between an open tag and a close one), and <DOWN> </DOWN> makes all inside the body letters lowercase. You are given the text consisting of latin letters and tags. Your task is to write the text right as it will be shown in the Bernet Explorer browser window. Tags in the text are arranged correctly, i.e. they form correct bracket sequence. If a letter lays inside several tags, its case is defined by the most inner tag.


The input contains the string S with the text. The length of the string is a natural number not exceeding 1000. Tags are always written in uppercase.


Write to the output text after the processing.


sample input
sample output