Company: Myntra_20sep
Difficulty: medium
Consistent Friend Lists Problem Description In a social media app, each user has a list of N friends, but each user sees themselves at the top of their own list. The rest of the list is ordered based on a secret algorithm. If there are N friends, the secret order is a permutation of [1, 2, ..., N]. For example, if the secret order is [2, 3, 1, 4], the friend lists would be: Friend 1 sees [1, 2, 3, 4] Friend 2 sees [2, 3, 1, 4] Friend 3 sees [3, 2, 1, 4] Friend 4 sees [4, 2, 3, 1] Given k screenshots of friend lists, your task is to determine if there exists a single secret order that could generate all the provided lists. Input Format The first line contains two integers n and k — the number of friends and the number of screenshots. The next k lines each contain n integers representing the friend list as seen by the friend at the top of that list. Output Format Print "Yes" if there exists at least one secret order that could produce all k screenshots. Otherwise, print "No". Examples Ex