2d matrix fast search algo