(de)serialize terrains