a=list(open('/dev/fd/0')) for b in a: i=0 for c in a*9:d=b[:i];i+=d==c[:i]*(b!=c) print d