i;char s[99][99],t[99],*u;main(c){for(;strcmp(gets(s[i]),"$");++i)(u=strstr(s[i],"@i"))&&memcpy(u,"%s",2);for(;gets(t),strcmp(t,"0");)for(c=0;c<i;++c,puts(""))printf(s[c],strstr(s[c],"%s")?gets(t):0);}
Note that non-ascii characters in the above source code will be escaped (such as \x9f).