#include <stdio.h>
int main()
{
int n,t;
while(scanf("%d",&n))
{
if(n==0)
break;
int c[205]={};
t = 1%n;
int i=0;
while(1)
{
i++;
if(c[t])
{
for(int j=c[t];j<i;j++)
printf("1");
for(int j=c[t]-1;j>=0;j--)
printf("0");
printf("\n");
break;
}
c[t]=i;
t =(t*10+1)%n;
}
}
return 0;
}