atcoder#ARC103C. [ARC103E] Tr/ee

[ARC103E] Tr/ee

Score : 700700 points

Problem Statement

You are given a string ss of length nn. Does a tree with nn vertices that satisfies the following conditions exist?

  • The vertices are numbered 1,2,...,n1,2,..., n.
  • The edges are numbered 1,2,...,n11,2,..., n-1, and Edge ii connects Vertex uiu_i and viv_i.
  • If the ii-th character in ss is 1, we can have a connected component of size ii by removing one edge from the tree.
  • If the ii-th character in ss is 0, we cannot have a connected component of size ii by removing any one edge from the tree.

If such a tree exists, construct one such tree.

Constraints

  • 2n1052 \leq n \leq 10^5
  • ss is a string of length nn consisting of 0 and 1.

Input

Input is given from Standard Input in the following format:

ss

Output

If a tree with nn vertices that satisfies the conditions does not exist, print -1.

If a tree with nn vertices that satisfies the conditions exist, print n1n-1 lines. The ii-th line should contain uiu_i and viv_i with a space in between. If there are multiple trees that satisfy the conditions, any such tree will be accepted.

1111
-1

It is impossible to have a connected component of size nn after removing one edge from a tree with nn vertices.

1110
1 2
2 3
3 4

If Edge 11 or Edge 33 is removed, we will have a connected component of size 11 and another of size 33. If Edge 22 is removed, we will have two connected components, each of size 22.

1010
1 2
1 3
1 4

Removing any edge will result in a connected component of size 11 and another of size 33.