Given a string , your task is to construct a compressed suffix tree for this string and output it.
The goal is to create a tree with the minimum number of vertices.
The input consists of a single line containing the string (1 \leq |s| \leq 10^5). The string ends with a dollar sign "", and all other characters are lowercase Latin letters.
Number the vertices of the tree from to n-1 using a depth-first search order, traversing subtrees based on the lexicographical order of the outgoing edges from each vertex. The order is determined by the ASCII values of the characters.
First, output an integer — the total number of vertices in the tree. Then, for the next n-1 lines, provide the description of each tree vertex, excluding the root, in ascending order of their numbers.
Each vertex is described by three integers: , , . Here, (0 \leq p < n, p \neq v) is the number of the parent vertex of . The edge from to is labeled with the substring s[lf \ldots rg-1] (0 \leq lf < rg \leq |s|).
Example 1
Example 2
Example 3
A substring s[l \ldots r] (0 \leq l \leq r < |s|) of the string s = s_0s_1 \ldots s_{|s|-1} (where is the length of the string ) is the sequence s_ls_{l+1} \ldots s_r.