z=scan("stdin","") for(j in 1:100){ i=0 while(i<-i+1)if(!any(grep(paste("^",x<-substr(z[j],1,i),sep=""),z[-j])))break write(x,1) }