You are given a string \(S\) and an integer \(K\). Print the valid partition of the string. A valid partition for a provided \(S\) and \(K\) satisfies the following properties:
- There exist strings \(s_1,s_2, ...,s_m\) where \(m \geq K\) such that \(s_1+s_2.....+s_m = S\) where \(+\) is the concatenation operator for strings.
- If \(1 \leq i \leq m-1\), then \(length(s_i) = K \).
- If \( i = m\), then \(K-1 \leq length(s_i) \leq K \).
If a valid partition is not possible, then print -1.
Print the strings \(s_1,s_2...,s_m\) in the partitions that are separated by '\(-\)'.
Input format
- First line: \(t\) denoting the number of test cases
- Next \(t\) lines: Space-separated string \(S\) and an integer \(K\)
Output format
For each test case, print a single line containing the valid partition.
Constraints
\(1 \leq t \leq 10\)
\(2 \leq |S| \leq 1000 \) where \(|S|\) is the length of string
\(1 \leq K \leq 30\)
1) Output satisfies valid partition properties for m = 3.
2) Output satisfies valid partition properties for m = 3.
3) No valid partition is possible.Please note that "dsda-svvc-jkx" is not a valid partition because there needs to be at least K groups
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor