N, m = map (int, input().split()) main, aux = {}, {} N = int(N/ 10) for i in range(1, m + 1): v, p, q = map(int, input().split()) v = int(v/10) if q == 0: main[(i, 0)] = (v, p*v) else: if (q, 0) not in aux: aux[(q, 0)] = (v, p*v) else: ...