Company: Google_SDE summer intern2027_4july
Difficulty: medium
There are N items from 1 to N available to make breakfast. Given M pairs of items (A i , B i )(1 ≤ i ≤ M), item A must come before item B while making breakfast. If making breakfast is not possible , then print -1. Otherwise, print the lexicographically-smallest arrangement of making breakfast. Input format The first line contains an integer T denoting the number of test cases. The first line of each test case contains two integers N and M denoting the number of items and their relationships respectively. Next M lines contain two space-separated integers denoting the relations. Output format Print -1 if making breakfast is not possible. Otherwise, print the lexicographically-smallest arrangement. Constraints 1 ≤ T ≤ 5 2 ≤ N ≤ 10 ^5 1 ≤ M ≤ min(10^5, (N * (N - 1))/2) Sample Input 1 1 4 5 2 4 4 3 2 3 1 4 2 1 Sample Output 1 2 1 4 3 Sample Input 1 1 4 4 1 2 4 2 3 3 2 3 Sample Output 1 1 4 2 3 Explanation If you consider the arrangement 4 1 2 3 , you will see that all the M pairs are satis