Python code for basic lattices