#include int main(int argc,char** argv) { for(char a='1',d[9],*p=d+1;gets(d);*p=a=a-*d?a-*p?a:*d:*p,puts(p)); return 0; }