at the top of the stairs , they skirted the edge of the dim subterranean abyss for several hundred yards , then entered one of the galleries where the ulgos lived and worked in small cubicles carved from the rock .