You are given a binary string
of length . Rearrange the binary string to form binary strings and such that the length of the longest common substring between andis minimum.
Print both strings
and.
Note that both
and must be anagrams of— see the examples below for more clarity.
Input Format
- The first line of input contains a single integer
- .
Output Format
- For each test case, output two lines. The first line contains string
- .
Constraints
- .
Subtasks
Subtask #1 (100 points): Original constraints
Sample Input 1
3
3
101
4
1111
4
0111
Sample Output 1
110
011
1111
1111
1101
0111
Explanation
Test case
: The given string is . Two rearrangements of such that the length of longest common substring is minimum are and . The longest common substring between strings and is , having length . It can be proved that for no other pair of rearrangements of string , the LCS has a length less than.
Test case
: The given string is . Here, all rearrangements of are the same. Two rearrangements of such that the length of longest common substring is minimum are and . The longest common substring between strings and is , having length.
Test case
: The given string is . Two rearrangements of such that the length of longest common substring is minimum are and . The longest common substring between strings and is having length . It can be proved that for no other pair of rearrangements of string , the LCS has a length less than .
ConversionConversion EmoticonEmoticon