Minutiae ranking and its application to fingerprint recognition