exponential version
Lexico works! O(m+n)