on social network consist m user friendship user user communicate know common languageyou give integ n array language array friendship wherethere n language number 1 nlanguagesi set language ith user know andfriendshipsi ui vi denote friendship user ui viYou choose language teach user friend communicate Return minimum number user need teachnote friendship transitive meaning x friend y y friend z do not guarantee x friend z Example 1input n 2 language 1212 friendship 121323output 1explanation you teach user 1 second language user 2 languageExample 2input n 3 language 213123 friendship 14123423output 2explanation Teach language user 1 3 yield user teach Constraints2 n 500languageslength m1 m 5001 languagesilength n1 languagesij n1 ui vi languageslength1 friendshipslength 500all tuple ui vi uniquelanguagesi contain unique value