FSM Problem 9004: 01(((10)*+111)*+0)*1

(ONLY FSM/DFA SOLUTIONS ACCEPTED)

(follow htis link for information on FSM submissions)

Description

Design a Finite State Machine (or Deterministic Finite Automaton) that recognises strings that match this regular expression:
        01(((10)*+111)*+0)*1
(Follow this link for an explanation of regular expressions)

Input Format

The input will be a sequence of lines of characters; each line contains only 0s and 1s, and is terminated by a single \n.

Output Format

For each input line output a single character, 'Y' if the line contains a string that the regular expression could generate, and 'N' if it doesn't.

At the end of the input (when the EOF symbol is reached) print a single \n and stop.

The output for this problem should be a single line, regardless of how many lines of input there are.

Sample Input

011
01101
011111
0101
0111111101111111
0111
011011

Sample Output

YYYYYNN

End of Problem