This page is still under construction.

Parts of this page are still being built. What you see may change.

Ping!

Time limit3sMemory limit128 MB

Summary
Recover all satellite intervals within the record whose combined odd-even pings produce the given binary record.
Level

Medium5 of 10

Topics
Greedy, Number theory, Simulation
Solved
No attempts yet

Problem

You are tracking a group of satellites. Each satellite broadcasts a ping at a fixed interval, and no two satellites use the same interval. Every satellite pings at time 0, and after that each one pings at every multiple of its own interval.

The pings cancel each other out. If an even number of satellites ping at a given time, you hear nothing. If an odd number ping at that time, you hear a single ping.

You are given the record of pings and silences, starting at time 0. Report every satellite that you can determine you can hear from where you are. The record is not always long enough to cover all of the intervals. A satellite that pings at time 0 but whose next ping falls past the end of the record leaves you with nothing to go on, so leave it out. Report only the satellites whose interval fits inside the record.

Input

The input has several test cases. Each test case is a single string on its own line, from 2 to 1,000 characters long. The first character is time 0, the next is time 1, and so on. Each character is either 0 or 1, telling you whether a ping is heard at that time (0 for no, 1 for yes). Every test case has at least one satellite that can be heard. The input ends with a line holding a single 0.

Output

For each test case, print the intervals of the satellites you know you can hear on one line, from smallest to largest, with a single space between them. Print no extra spaces, and do not separate the answers with blank lines.

Examples1

  1. Example 1

    Input
    01000101101000
    1001000101001000
    0
    
    Expected output
    1 2 3 6 8 10 11 13
    3 6 7 12 14 15