QOJ.ac

QOJ

実行時間制限: 1.0 s メモリ制限: 1024 MB 満点: 100 ハック可能 ✓

#15313. Replacement

統計

Given a binary string $s$ of length $n$ ($01$ string). You need to replace one character in $s[2 \ldots n - 1]$ with $\oplus$, so that the final value of the expression is as large as possible.

$\oplus$ represents the binary XOR operation. After the replacement, both sides of $\oplus$ are treated as binary numbers.

Input

A single test case contains multiple data sets.

The first line of input is the number of data sets $T$ ($1 \le T \le 10^5$), representing the number of data sets in this test case.

For each data set, there is one line containing a binary string $s$ ($3 \le |s| \le 5 \cdot 10^5$).

It is guaranteed that in a single test case, $\sum |s| \le 5 \cdot 10^5$.

Output

For each data set, output one line containing a binary string that represents the largest result in binary form (the number string cannot contain leading $0$s except for the single digit $0$).

Examples

Input 1

5
010
0110
1000
10101
01000

Output 1

0
10
10
100
10

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.