you give list preference n friend n evenFor person preferencesi contain list friend sort order preference in word friend early list prefer friend later list Friends list denote integer 0 n1all friend divide pair the pairing give list pair pairsi xi yi denote xi paired yi yi pair xiHowever pair cause friend unhappy a friend x unhappy x pair y exist friend u pair v butx prefer u y andu prefer x vReturn number unhappy friend Example 1input n 4 preference 1 2 3 3 2 0 3 1 0 1 2 0 pair 0 1 2 3output 2ExplanationFriend 1 unhappy 1 pair 0 prefer 3 0 3 prefer 1 2friend 3 unhappy 3 pair 2 prefer 1 2 1 prefer 3 0friends 0 2 happyexample 2input n 2 preference 1 0 pair 1 0output 0explanation both friend 0 1 happyExample 3input n 4 preference 1 3 2 2 3 0 1 3 0 0 2 1 pair 1 3 0 2output 4 Constraints2 n 500n evenpreferenceslength npreferencesilength n 10 preferencesij n 1preferencesi contain iAll value preferencesi uniquepairslength n2pairsilength 2xi yi0 xi yi n 1each person contain exactly pair