1d dp, 2way scan