#include<cstdio> int Sum(int n) { int sum=0; while(n!=0) { sum+=n%10; n/=10; } return sum; } void Cal(int a,int b) { while(a!=b) { if(a<b) { a+=Sum(a); } else { b+=Sum(b); } } printf("%d ",a); } int main() { int n; int count=1; while(~scanf("%d",&n)&&n) { if(count>1) printf(" "); printf("Case #%d ",count++); int nn=Sum(n); if(nn%9==0) { printf("first meets river 9 at "); Cal(9,n); } else if(nn%3==0) { printf("first meets river 3 at "); Cal(3,n); } else { printf("first meets river 1 at "); Cal(1,n); } } }