using System.Linq; using System.Collections.Generic; using System; public class P { public int xor { get; set; } public int to { get; set; } } public class Hello { static void Main() { string[] line = Console.ReadLine().Trim().Split(' '); var n = int.Parse(line[0]); var m = int.Parse(line[1]); var aa = new List
[n]; for (int i = 0; i < n; i++) aa[i] = new List
(); var check = new int[m, 3]; for (int i = 0; i < m; i++) { line = Console.ReadLine().Trim().Split(' '); var t0 = int.Parse(line[0]) - 1; var t1 = int.Parse(line[1]) - 1; var t2 = int.Parse(Console.ReadLine().Trim()); aa[t0].Add(new P { to = t1, xor = t2 }); aa[t1].Add(new P { to = t0, xor = t2 }); check[i, 0] = t0; check[i, 1] = t1; check[i, 2] = t2; } getAns(n, m, aa, check); } static void getAns(int n, int m, List
[] aa, int[,] check)
{
var ans = new int[n];
for (int i = 0; i < n; i++) ans[i] = -1;
var q = new Queue