Problem:
Score : 700 points

Problem Statement

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

The vertices are numbered 1,2,..., n.

The edges are numbered 1,2,..., n-1, and Edge i connects Vertex u_i and v_i.

If the i-th character in s is 1, we can have a connected component of size i by removing one edge from the tree.

If the i-th character in s is 0, we cannot have a connected component of size i by removing any one edge from the tree.

If such a tree exists, construct one such tree.

Constraints

2 \leq n \leq 10^5

s is a string of length n consisting of 0 and 1.

Input

Input is given from Standard Input in the following format:

s

Output

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

If a tree with n vertices that satisfies the conditions exist, print n-1 lines.
The i-th line should contain u_i and v_i with a space in between.
If there are multiple trees that satisfy the conditions, any such tree will be accepted.

Sample Input 1

1111

Sample Output 1

-1

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

Sample Input 2

1110

Sample Output 2

1 2
2 3
3 4

If Edge 1 or Edge 3 is removed, we will have a connected component of size 1 and another of size 3. If Edge 2 is removed, we will have two connected components, each of size 2.

Sample Input 3

1010

Sample Output 3

1 2
1 3
1 4

Removing any edge will result in a connected component of size 1 and another of size 3.

Solution in Rust (1.15.1) (judge verdict: Accepted)

fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim_right().to_owned()
}

fn str_to_ints(s: String) -> std::vec::Vec<i64> {
    let mut ret = std::vec::Vec::new();
    let ws = s.split_whitespace();
    for w in ws {
        ret.push(w.parse().unwrap());
    }
    ret
}

fn read_ints() -> std::vec::Vec<i64> {
    str_to_ints(read_line())
}

fn main() {
    let s = read_line();
    let mut s_vec: std::vec::Vec<i64> = std::vec::Vec::new();

    for c in s.chars() {
        if c == '1' {
            s_vec.push(1);
        } else {
            s_vec.push(0);
        }
    }

    if s_vec[0] != 1 || s_vec[s.len() - 1] != 0 {
        println!("-1");
        return
    }
    for i in 0..(s.len() / 2) {
        if s_vec[i] != s_vec[s.len() - i - 2] {
            println!("-1");
            return
        }
    }
    let mut s_vec_prime: std::vec::Vec<i64> = std::vec::Vec::new();
    for i in 0..s_vec.len() {
        if i == s_vec.len() - 1 {
            s_vec_prime.push(1);
        } else {
            s_vec_prime.push(s_vec[i]);
        }
    }

    let mut parents: std::vec::Vec<i64> = std::vec::Vec::new();
    let mut tmp_parent: i64 = s.len() as i64;
    for i in (0..(s.len() - 1)).rev() {
        if s_vec_prime[i + 1] == 1 {
            tmp_parent = i as i64 + 2;
        }
        parents.insert(0, tmp_parent);
    }

    for i in 0..(s.len() - 1) {
        println!("{} {}", i+1, parents[i]);
    }
}