longest common prefix O(mn)