human
Breaking Good is a new video game which a lot of gamers want to have. There is a certain level in the game that is really difficult even for experienced gamers.

Walter William, the main character of the game, wants to join a gang called Los Hermanos (The Brothers). The gang controls the whole country which consists of n cities with m bidirectional roads connecting them. There is no road is connecting a city to itself and for any two cities there is at most one road between them. The country is connected, in the other words, it is possible to reach any city from any other city using the given roads. 

The roads aren't all working. There are some roads which need some more work to be performed to be completely functioning.

The gang is going to rob a bank! The bank is located in city 1. As usual, the hardest part is to escape to their headquarters where the police can't get them. The gang's headquarters is in city n. To gain the gang's trust, Walter is in charge of this operation, so he came up with a smart plan.

First of all the path which they are going to use on their way back from city 1 to their headquarters n must be as short as possible, since it is important to finish operation as fast as possible.

Then, gang has to blow up all other roads in country that don't lay on this path, in order to prevent any police reinforcements. In case of non-working road, they don't have to blow up it as it is already malfunctional. 

If the chosen path has some roads that doesn't work they'll have to repair those roads before the operation.

Walter discovered that there was a lot of paths that satisfied the condition of being shortest possible so he decided to choose among them a path that minimizes the total number of affected roads (both roads that have to be blown up and roads to be repaired).

Can you help Walter complete his task and gain the gang's trust?

Input

The first line of input contains two integers n, m (2 ≤ n ≤ 105, ), the number of cities and number of roads respectively.

In following m lines...
Using python3 can you solve the prior task?
assistant
#Here is the Python code you requested.

f = lambda: map(int, input().split())
g = lambda: (a.i, b.i) if a.i < b.i else (b.i, a.i)

class T:
    def __init__(t, i):
        t.i = i
        t.s = t.v = t.u = 0
        t.p = []

n, m = f()
t = [T(i) for i in range(n + 1)]
d, l = [], []
for k in range(m):
    i, j, q = f()
    a, b = t[i], t[j]
    a.p.append(b)
    b.p.append(a)
    if q: d += [g()]
d = set(d)
x, y = [], []
a = t[1]
a.u = 1
while a.i < n:
    for b in a.p:
        v = a.v + (g() in d)
        if not b.u or b.u > a.u and v > b.v: b.v, b.s = v, a.i
        if not b.u:
            b.u = a.u + 1
            y.append(b.i)
    if not x:
        x, y = y, x
        x.reverse()
    a = t[x.pop()]
while a.i > 1:
    b = t[a.s]
    a.p.remove(b)
    b.p.remove(a)
    if g() in d: d.remove(g())
    else: l += [(a.i, b.i)]
    a = b
print(len(l) + len(d))
for a, b in l: print(a, b, 1)
for a, b in d: print(a, b, 0)