WIP: the cubes; brute force solution using visited flag map.