FSM Problem 9003: 10+(0+11)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:
        10+(0+11)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

10
101
1101
11000000001
110000000
01
011

Sample Output

YNYYNYN

End of Problem