For convenience, the comma replaced the hyphen.
At the entrance, a set of numeric arrays. Example:
2-1-2-0-6-7 2-1-2-0-7-0 2-1-2-0-7-1-2-1-3-1-6 2-1-2-0-7-1-2-1-3-2-8 2-1-2-0-7-1-3-4 2-1-2-0-7-1-3-5 2-1-2-0-7-1-4 2-1-2-0-7-1-4-6 2-1-2-0-8 2-1-2-2 The output should be a tree whose vertices are the initial subarrays of the arrays subordinate to them. New arrays can be created, but if new arrays are created, each vertex should subordinate at least two arrays to itself, that is, if only one class abcde is in class ab, then it is not necessary to allocate class ab (unless ab is specified at the input) by inserting to class a directly abcde.
From the example given by me, the following should be obtained, with preservation of the hierarchical structure, it is expressed by spaces here:
2-1-2 (создаётся класс) 2-1-2-0 (создаётся класс) 2-1-2-0-6-7 2-1-2-0-7 (создаётся класс) 2-1-2-0-7-0 2-1-2-0-7-1 (создаётся класс) 2-1-2-0-7-1-2-1-3 (создаётся класс) 2-1-2-0-7-1-2-1-3-1-6 2-1-2-0-7-1-2-1-3-2-8 2-1-2-0-7-1-3 (создаётся класс) 2-1-2-0-7-1-3-4 2-1-2-0-7-1-3-5 2-1-2-0-7-1-4 2-1-2-0-7-1-4-6 2-1-2-0-8 2-1-2-2 It is important that when the processor encounters an array of 2-1-2-0-7-1-3-4, it must create a class of 2-1-2-0-7-1, and lay it between class 2-1-2 -0-7 and 2-1-2-0-7-1-2-1-3 (the latter is obtained during the initial comparison of the two previous arrays), since in this class the array 2-1-2-0- will be placed later 7-1-3-4 (in this case, indirectly), not being a representative of class 2-1-2-0-7-1-2-1-3, but belonging to class 2-1-2-0-7 -1, which is created.
The programming language is java whenever possible, but not necessarily - the sorting principle is important.