Few people have heard of Pozo Azul (pronounced po-tho a-thool), but for the past few summers it has become the focus of attention of Europe's foremost cave-diving explorers. Some 30 miles north of Burgos lies the small village of Covanera, high among the headwaters of the Ebro Valley in northern Spain. It's a beautiful spot on the busy main road between Burgos and Santander, nestling beneath spectacularly sculpted cliffs at an altitude of about 700m. But unless you stop at the tiny Bar Muñecas — a staging post for explorers of Pozo Azul — beside the road, you'd never know that you were just a few hundred meters away from one of the longest cave dives in the world.

Pozo Azul
Entrance of Pozo Azul.

Pozo Azul is the most audacious exploratory cave-diving project of recent times and pushes the absolute limits of what is possible: it's serious stuff for all involved. Cave explorations progress slowly, depending on the location, the conditions, and the equipment, time and money available. The Spanish pioneered this cave in 1964, passing the spectacular first sump in 1979 and establishing Pozo Azul as the longest cave dive in the country. In 1991, another progression, by Spain’s GE Gaia team, took the cave's known length to a total of 1.780m.

Then, in the summer of 2001, British cave diver Jason Mallinson made a visit to the area. He had come to Spain shortly after his epic dives with Rick Stanton at the Emergence du Ressel in Lot, southwest France. Jason knew from the outset what was required to explore the cave further. Well used to working alone and a highly skilled rope-access technician, he installed wire hawsers along the stream-way between sumps so that the heavy scooters could be transported to the front line with less risk of damage. Unlike the one-day operations that typified the majority of cave diving operations, this one employed tactics akin to a siege. An advance base was set beyond Sump 1, and in 2003, the first of several underwater decompression habitats was transported and installed a short distance into Sump 2.  The villagers took Jason to heart, and as word spread, he gained the confidence and support of leading Spanish amateur divers, who have taken their holiday time to assist with the project.

Jason had invested seven years to gain a point 3.530m in Sump 2 when, in May 2008, a rival team of divers from Germany recognized the potential and mounted their own push on the cave. While they quickly proved their caliber by progressing a further 490m, their incursion to an ongoing project flew in the face of accepted protocol and soured relations within the diving community.

Pozo Azul
Cross section of Pozo Azul showing an overview of the different expeditions that explored the cave over the years.

Ethics are very difficult in a case such as this: there is no way that the British team could argue over a Spanish cave. But at the same time, it served to spur Jason into action. Adding further insult, the German team refused to supply details of the trend of the cave. Did it continue at depth or might the tunnel finally be surfacing? Such information is crucial in dive planning.

Jason made another dive in August 2007, which ran to ten hours — two getting in, two out, getting to the end and back, and six on decompression. He had pushed his Kiss rebreather well beyond its accepted duration and was approaching a similar position with his scooters. Given the distance and depth of the dive, every aspect of the operation was reappraised, and now he felt that it was time to draw on the full expertise of his peers. With the British divers John Volanthen and Rick Stanton and the Dutch caver René Houben he formed a team of lead divers to start a counterattack on the German team.

In 2009 the team was the first to succeed in passing the complete passage of Sump 2 after a total distance of 5.160m, to reach a small dry cave area they nicknamed Tipperary where they discovered a third sump. In 2011 the team passed Sump 3 after 3.275m to find an active streamway with numerous cascades leading to a fourth sump. To reach this point 9.135m of diving was required, from the entrance. In 2013 Sump 4 was reached after an epic carry, and found to be only 140m long. A fast flowing river canyon followed, with sharp eroded rock, and progress was halted after 300m due to the risk of drysuit damage. 2014 saw different tactics used to progress at the end of the cave, when the divers changed into wetsuits to combat the dangerous situation with the sharp rocks. A fifth sump was discovered several hundred meters beyond Sump 4. The total dive distance to the end now was 9.375m and the total cave passages including dry passages has shot up to more than 12.000m. In 2015 Jason Mallinson did a solo push at the end, after an epic 3 day trip, and a sixth sump was discovered and dived. This was followed by nearly 1000m of new dry passages. More than ever the question raises whether this cave will ever stop?

Assignment

In this assignment we process cross sections showing the various corridors of a cave. A cross section is subdivided into squares that form a rectangular $$r \times c$$ grid with $$r$$ rows and $$c$$ columns. Each square contains a part of a corridor that connects two sides of the square with each other. The corridor that passes through the square is described by a string of two uppercase letters that correspond to the cardinal directions of the two sides of the square that are connected with each other by the corridor: north (N), south (S), east (E) and west (W). The entrance to the cave is always located at the north side of northwesternmost square of the grid. Below you see an example of a cross section of a cave, where the corridors are shown both graphically and with their string representation.

cave

Your exploration mission is to determine the depth of a given cave. The depth of the cave is expressed as the number of squares that can be reached by following the corridor from the entrance, until it is blocked or hits the edge of the cave. In doing so, you proceed as follows:

Example

The cave described in the first part of the following sample session corresponds to the cave depicted in the above graphical representation.

>>> crossSection(4, 'NSSWNSSWNWNWEWSWNSSEEWSWEWSENSSWNENWNSNEEWEWSWSENWNESEEWNWNWSESW')
[['NS', 'SW', 'NS', 'SW', 'NW', 'NW', 'EW', 'SW'], ['NS', 'SE', 'EW', 'SW', 'EW', 'SE', 'NS', 'SW'], ['NE', 'NW', 'NS', 'NE', 'EW', 'EW', 'SW', 'SE'], ['NW', 'NE', 'SE', 'EW', 'NW', 'NW', 'SE', 'SW']]
>>> crossSection(4, 'NSSWNSSWNWNWEWSWNSS')
Traceback (most recent call last):
AssertionError: invalid cross section

>>> cave = crossSection(4, 'NSSWNSSWNWNWEWSWNSSEEWSWEWSENSSWNENWNSNEEWEWSWSENWNESEEWNWNWSESW')
>>> depth(cave)
11