Decomposable Single Word Languages

아직 제출이 없습니다시간 제한2초메모리 제한512 MB

문제

Deterministic finite automaton (DFA) is an ordered set Σ,U,S,T,φ\langle\Sigma, U, S, T, \varphi\rangle where Σ\Sigma is the finite set called input alphabet, in this problem Σ=\mboxa,b,...,z\Sigma = \\{\mbox{a, b, ..., z}\\}, UU is the finite set of states, SUS \in U is the initial state, TUT \subset U is the set of terminal states and φ:U×ΣU\varphi : U \times \Sigma \rightarrow U is the transition function

The input of the automaton is the string α\alpha over Σ\Sigma. Initially the automaton is in state ss. Each step the automaton reads the first character cc of the input string and changes its state to φ(u,c)\varphi(u, c) where uu is the current state. Then the first character of the input string is removed and the step repeats. If after its input string is empty the automaton is in the terminal state, it accepts the initial string α\alpha, in the other case it rejects it. The set of all words accepted by an automaton AA is denoted as L(A)L(A).

One can visualize DFA as a directed graph representing its states as vertices and its transitions as edges marked with characters. Terminal states are shown as double circled vertices, the initial state is marked by an arrow. The picture below on the left shows the automaton for a language (ab)\*(ab)^\* of words that consist of zero or more repeated words "ab". The picture below on the right shows the automaton for a language a\*ba\*ba\*a^\*ba^\*ba^\* that consist of "a" and "b" and contain two "b"-s. For sake of clarity edges marked by "\*\*" represent all transitions not explicitly drawn.

A set XX of words is called a regular language if it is equal to L(A)L(A) for some DFA AA. The index of a regular language XX denoted as ind(X)ind(X) is the minimal number of states in a DFA AA such that L(A)=XL(A) = X. For example, the two automatons shown on the picture above are indeed the minimal DFA-s for the described languages, so ind((ab)\*)=3ind((ab)^\*)=3 and ind(a\*ba\*ba\*)=4ind(a^\*ba^\*ba^\*)=4.

It is well known that if X_1X\_1 and X_2X\_2 are two regular languages its intersection X_1X_2X\_1 \cap X\_2 is also a regular language. For example, the intersection of the two languages described above is the language Y=(ab)\*(a\*ba\*ba\*)=ababY=(ab)^\*\cap\left(a^\*ba^\*ba^\*\right)=\\{abab\\} that contains a single word "abab". Clearly a single word language is regular, the automaton for YY is shown on the picture below.

It is easy to see that if WW is a single word language W=wW = \\{w\\}, and length of ww is nn, the index of WW is equal to n+2n+2.

A regular language XX is called decomposable if XX can be represented as an intersection of two regular languages X=X_1X_2X = X\_1 \cap X\_2 and ind(X)>ind(X_1)ind(X) > ind(X\_1) and ind(X)>ind(X_2)ind(X) > ind(X\_2). For example, the single word language Y=\mboxababY=\\{\mbox{abab}\\} is decomposable.

Given a word ww of length nn find whether the single word language W=wW = \\{w\\} is decomposable and if it is, find two automatons A_1A\_1 and A_2A\_2 such that number of states in both A_1A\_1 and A_2A\_2 is less than n+2n+2 and W=L(A_1)L(A_2)W = L(A\_1)\cap L(A\_2).

입력

The input file contains multiple test cases.

Each test case consists of a word ww on a line on itself, ww consists of lowercase letters of the English alphabet, length of ww is between 1 and 50, inclusive.

There are at most 100 tests in one input file.

출력

For each test case first print <<YES>> if the corresponding single-word language is decomposable, or <<NO>> if it is not. If the language is decomposable, the description of two DFA-s must follow. Each DFA description must start with kk --- the number of states, 1kn+11 \le k \le n + 1, where nn is the length of the input word. Let states be numbered from 1 to kk, the initial state is the state number 1. Then print tt --- the number of terminal states, 1tk1 \le t \le k, followed by tt integers from 1 to kk --- terminal states. The following kk lines must contain 26 integers each: for a state uu print φ(u,\mboxa)\varphi(u, \mbox{a}), φ(u,\mboxb)\varphi(u, \mbox{b}), \dots, φ(u,\mboxz)\varphi(u, \mbox{z}).