P2841 A*B Problem

Description

Given a number $A$, you need to output the smallest number $B$ such that the result of $A \times B$ contains only digits 0 and 1.

Input Format

A positive integer $A$.

Output Format

The positive integer $B$ and the result of $A \times B$, separated by a single space.

Explanation/Hint

Sample explanation: $6 \times 185 = 1110$. For 30% of the testdata, $0 < A < 20$. For 50% of the testdata, $0 < A < 100$. For 70% of the testdata, $0 < A < 1000$. For 100% of the testdata, $0 < A < 10^4$. Translated by ChatGPT 5