partial derangement
extended euclidean