Dam with Y-fronts

parse took 0.12018013000488
mysql: 23 queries took 0.011500120162964