Median and N-Queens