#include using namespace std; long long n,x,y; int main() { cin>>n>>x>>y; while(x || y || n ) { int pas=0; int aux[6]; while(n) { (n%10==x ? aux[pas++]=y : aux[pas++]=n%10); n/=10; } for(int i=pas-1;i>=0;i--) cout<>n>>x>>y; } return 0; }