human
After a successful field test, Heidi is considering deploying a trap along some Corridor, possibly not the first one. She wants to avoid meeting the Daleks inside the Time Vortex, so for abundance of caution she considers placing the traps only along those Corridors that are not going to be used according to the current Daleks' plan – which is to use a minimum spanning tree of Corridors. Heidi knows that all energy requirements for different Corridors are now different, and that the Daleks have a single unique plan which they are intending to use.

Your task is to calculate the number E_{max}(c), which is defined in the same way as in the easy version – i.e., the largest e ≤ 10^9 such that if we changed the energy of corridor c to e, the Daleks might use it – but now for every corridor that Heidi considers. 

Input

The first line: number n of destinations, number m of Time Corridors (2 ≤ n ≤ 10^5, n - 1 ≤ m ≤ 10^6). The next m lines: destinations a, b and energy e (1 ≤ a, b ≤ n, a ≠ b, 0 ≤ e ≤ 10^9).

No pair \\{a, b\} will repeat. The graph is guaranteed to be connected. All energy requirements e are distinct.

Output

Output m-(n-1) lines, each containing one integer: E_{max}(c_i) for the i-th Corridor c_i from the input that is not part of the current Daleks' plan (minimum spanning tree).

Example

Input

3 3
1 2 8
2 3 3
3 1 4

Output

4

Note

If m = n-1, then you need not output anything.
 ... What is a Python code to calculate the number E_{max}(c), which is defined in the same way as in the easy version – i?
assistant
#Here is Python code to calculate the number E_{max}(c), which is defined in the same way as in the easy version – i.

def naiveSolve():
    
    
    
    return

from types import GeneratorType
def bootstrap(f, stack=[]):
    def wrappedfunc(*args, **kwargs):
        if stack:
            return f(*args, **kwargs)
        else:
            to = f(*args, **kwargs)
            while True:
                if type(to) is GeneratorType:
                    stack.append(to)
                    to = next(to)
                else:
                    stack.pop()
                    if not stack:
                        break
                    to = stack[-1].send(to)
            return to
    return wrappedfunc

class UnionFind:
    def __init__(self, n):
        self.parent = list(range(n))
    def find(self, a): #return parent of a. a and b are in same set if they have same parent
        acopy = a
        while a != self.parent[a]:
            a = self.parent[a]
        while acopy != a: #path compression
            self.parent[acopy], acopy = a, self.parent[acopy]
        return a
    def union(self, a, b): #union a and b
        self.parent[self.find(b)] = self.find(a)

def main():
    
    n,m=readIntArr()
    a=[]
    b=[]
    c=[]
    for _ in range(m):
        aa,bb,cc=readIntArr()
        a.append(aa); b.append(bb); c.append(cc)
    
    idxes=list(range(m))
    idxes.sort(key=lambda i:c[i])
    
    uf=UnionFind(n+1)
    inA=[] # in MST
    inB=[]
    inC=[]
    outA=[] # not in MST
    outB=[]
    outIdxes=[]
    for i in range(m):
        aa=a[idxes[i]]
        bb=b[idxes[i]]
        cc=c[idxes[i]]
        if uf.find(aa)!=uf.find(bb):
            uf.union(aa,bb)
            inA.append(aa)
            inB.append(bb)
            inC.append(cc)
        else:
            outIdxes.append(idxes[i])
    outIdxes.sort()
    for i in outIdxes:
        outA.append(a[i])
        outB.append(b[i])
    
    # find largest edge between each outA and outB
    adj=[[] for _ in range(n+1)] # store (edge,cost)
    assert len(inA)==n-1
    for i in range(n-1):
        u,v,c=inA[i],inB[i],inC[i]
        adj[u].append((v,c))
       ...