Implemented 2DBfs.