Smith Normal form