//7.9做的....但是当时RE了,就不想在调试了....今天重看了下,发现输入少了个条件,即不为0
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
typedef unsigned long long LL;
bool flag;
void dfs(LL t, LL n, int k)
{
if(k==19 || flag){
return;
}
// cout << t << " " << n << endl;
if((t%n == 0)){
flag = true;
cout << t << endl;
return;
}
dfs(t*10, n, k+1);
dfs(t*10+1, n, k+1);
}
int main()
{
LL n;
while(cin >> n && n){
dfs(1, n, 0);
flag = false;
}
return 0;
}