QOJ.ac

QOJ

时间限制: 1.0 s 内存限制: 1024 MB 总分: 100 可 Hack ✓

#15239. Generate 01 String

统计

Siri has discovered a magical symbol $S$, which can undergo two types of operations:

  1. Clicking on a symbol $S$ will turn it into $0S1S$.
  2. Clicking on a symbol $S$ will turn it into $1S0S$.

At any point, you can choose to make all symbols disappear, leaving only the $0$ and $1$ characters in the string. Now Siri wants to know if it is possible to obtain a given binary string $T$ through some sequence of operations.

Input

A single binary string $T$ ($1 \le |T| \le 10^6$).

Output

If a solution exists, output the number of operations $n$ ($1 \le n \le 10^6$) on the first line. Then output $n$ lines, each containing two space-separated integers $pos$ and $op$, representing that you perform operation $op$ on the $pos$-th symbol in the current string. Otherwise, output -1.

Examples

Input 1

0011

Output 1

2
1 1
1 1

Note

Explanation of the example: Initially $S$. First operation on 1, resulting in $0S1S$. Second operation on 1, resulting in $00S1S1S$. After the symbols $S$ disappear, we get $0011$.

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.