def g(s,l):n=len(s);u=[i for i in l if~-(s in{*l}-{i})*(i[:n]==s)];return~len(u)and~(len(u[0])-n)%2or-min(g(i[:n+1],l)for i in u)

A 1 indicates the current player will win, whereas a -1 indicates they will lose.