import java.io.*; import java.util.Arrays; class Main{ static final PrintWriter out=new PrintWriter(System.out); static final int INF=Integer.MIN_VALUE/2; public static void main(String[] args) throws IOException{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String line=br.readLine(); int n=Integer.parseInt(line.split(" ")[0]); int m=Integer.parseInt(line.split(" ")[1]); int[][] score=new int[n][n]; int[] a=new int[n]; while(m-->0){ line=br.readLine(); int x=Integer.parseInt(line.split(" ")[0]); int y=Integer.parseInt(line.split(" ")[1]); score[x][y]=Integer.parseInt(line.split(" ")[2]); } for(int i=0;i=0;i--){ if(a[i]