shortest word path problem