This page is still under construction.

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

Finding a Multiple

Interview

Time limit1sMemory limit128 MB

Summary
For each n up to 200, print the smallest multiple of n whose decimal digits are only 0 and 1, with up to 100 digits.
Level

Medium6 of 10

Topics
BFS, Number theory, Math, String matching
Solved
No attempts yet

Problem

Given a positive integer nn, consider a positive integer mm that is a multiple of nn and whose decimal representation consists only of the digits 0 and 1. Such an mm always exists. Write a program that finds the smallest such mm.

Here nn is a positive integer of at most 200, and the smallest valid mm has at most 100 digits.

Input

The input consists of several test cases. Each line contains one integer nn (1≤n≤2001 \le n \le 200). The last line contains 00 and must not be processed.

Output

For each test case, print on its own line the smallest mm that satisfies the condition.

Examples2

  1. Example 1

    Input
    2
    6
    19
    0
    
    Expected output
    10
    1110
    11001
    
  2. Example 2

    Input
    3
    5
    7
    0
    
    Expected output
    111
    10
    1001