405895: GYM102154 A Addition without carry
Description
It's surprising but sometimes we can use the bitwise OR to add positive integers written in the binary notation. For a set of numbers, if there are no two numbers with 1 at the same position (counting positions from the right), then the sum of those numbers is equal to their bitwise OR. Such sets of numbers are called beautiful.
You are given a set of positive integers a1, a2, ..., an. You must build a beautiful set of positive integers b1, b2, ..., bn so that the condition bi ≥ ai holds true, and the sum b1 + b2 + ... + bn is minimized.
Given the binary notation of the numbers a1, a2, ..., an, find the binary notation of the minimum possible value of the sum of numbers in the desired beautiful set b1, b2, ..., bn.
InputThe first line of the input contains an integer n — the size of the given set (2 ≤ n ≤ 300 000). This is also equal to the size of the sought set (bi).
The i-th of the next n lines contains a binary notation of a positive integer ai. The numbers do not contain leading zeros, and the total length of their binary notations does not exceed 300 000.
OutputPrint the binary notation of the minimum possible sum of numbers in the desired beautiful set b1, b2, ..., bn. Don't print leading zeros.
ScoringLet max L be the maximum length of a binary notation of ai.
You will get points for a group if you pass all tests in this group and all groups listed in the dependencies. The group 0 denotes the sample test(s) from the statement.
ExamplesInput2 10 10Output
110Input
2 10100 1001Output
11101Input
3 1 1 110Output
1011