Under construction

Still being built. Things may change

Syntax Included

Time limit1sMemory limit128 MB

Summary
Parse each HTML-like string against the given grammar and decide whether it is syntactically valid.
Level

Medium7 of 10

Topics
String, Recursion, Implementation, Brute force
Solved
No attempts yet

Problem

You are building your first website and keep making simple HTML syntax mistakes. To catch them, you decide to write an HTML parser that determines whether your HTML code is syntactically correct, based on the following condensed HTML definition:

HTMLCODE<HTML>BODY</HTML>
BODY<BODY>TEXT</BODY>
TEXTSTRING | STRING TEXT | TAG | TAG TEXT
STRINGa possibly empty run of printable characters other than < and >
TAGBOLD | ITALICS | LINK
BOLD<B>TEXT</B>
ITALICS<I>TEXT</I>
LINK<A HREF=URL>TEXT</A>
URLhttp://STRING.com

Input

The first line contains a single integer nn, the number of data sets.

Each of the following nn lines contains one data set of up to 1000 characters. Spaces may appear anywhere within a data set.

All tags are case sensitive.

Output

For each data set, print one line.

If the code is syntactically correct, print:

Syntax Included

Otherwise, print:

No Syntax Included

Examples3

  1. Example 1

    Input
    3
    <HTML><BODY><B>Hello world!</B></BODY></HTML>
    <HTML><BODY><B>Is this correct?</B></HTML>
    <HTML><BODY><A HREF=http://www.go.com>link</A></BODY></HTML>
    
    Expected output
    Syntax Included
    No Syntax Included
    Syntax Included
    
  2. Example 2

    Input
    1
    <HTML><BODY></BODY></HTML>
    
    Expected output
    Syntax Included
    
  3. Example 3

    Input
    1
    <HTML><BODY><B><I>hi</I></B></BODY></HTML>
    
    Expected output
    Syntax Included