There are many anime that are about "love triangles": Alice loves Bob, and Charlie loves Bob as well, but Alice hates Charlie. You are thinking about an anime which has n characters. The characters are labeled from 1 to n. Every pair of two characters can either mutually love each other or mutually hate each other (there is no neutral state).

You hate love triangles (A-B are in love and B-C are in love, but A-C hate each other), and you also hate it when nobody is in love. So, considering any three characters, you will be happy if exactly one pair is in love (A and B love each other, and C hates both A and B), or if all three pairs are in love (A loves B, B loves C, C loves A).

You are given a list of m known relationships in the anime. You know for sure that certain pairs love each other, and certain pairs hate each other. You're wondering how many ways you can fill in the remaining relationships so you are happy with every triangle. Two ways are considered different if two characters are in love in one way but hate each other in the other. Print this count modulo 1 000 000 007.


-----Input-----

The first line of input will contain two integers n, m (3 ≤ n ≤ 100 000, 0 ≤ m ≤ 100 000).

The next m lines will contain the description of the known relationships. The i-th line will contain three integers a_{i}, b_{i}, c_{i}. If c_{i} is 1, then a_{i} and b_{i} are in love, otherwise, they hate each other (1 ≤ a_{i}, b_{i} ≤ n, a_{i} ≠ b_{i}, $c_{i} \in \{0,1 \}$).

Each pair of people will be described no more than once.


-----Output-----

Print a single integer equal to the number of ways to fill in the remaining pairs so that you are happy with every triangle modulo 1 000 000 007. 


-----Examples-----
Input
3 0

Output
4

Input
4 4
1 2 1
2 3 1
3 4 0
4 1 0

Output
1

Input
4 4
1 2 1
2 3 1
3 4 0
4 1 1

Output
0



-----Note-----

In the first sample, the four ways are to:   Make everyone love each other  Make 1 and 2 love each other, and 3 hate 1 and 2 (symmetrically, we get 3 ways from this). 

In the second sample, the only possible solution is to make 1 and 3 love each other and 2 and 4 hate each other.

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

ns = {"__name__": "__main__"}
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = 'class DisjointSet(object):\n    def __init__(self, n):\n        self.parent = list(range(n))\n        self.rank = [0] * n\n        self.num = n  # number of disjoint sets\n\n    def union(self, x, y):\n        self._link(self.find_set(x), self.find_set(y))\n\n    def _link(self, x, y):\n        if x == y:\n            return\n        self.num -= 1\n        if self.rank[x] > self.rank[y]:\n            self.parent[y] = x\n        else:\n            self.parent[x] = y\n            if self.rank[x] == self.rank[y]:\n                self.rank[y] += 1\n\n    def find_set(self, x):\n        xp = self.parent[x]\n        if xp != x:\n            self.parent[x] = self.find_set(xp)\n        return self.parent[x]\n\n\ndef solve():\n    n, m = list(map(int, input().split()))\n    ds = DisjointSet(n * 2)\n    for i in range(m):\n        a, b, c = list(map(int, input().split()))\n        a -= 1\n        b -= 1\n        aA = a * 2\n        aB = aA + 1\n        bA = b * 2\n        bB = bA + 1\n        if c == 0:\n            if ds.find_set(aA) == ds.find_set(bA):\n                return 0\n            ds.union(aA, bB)\n            ds.union(aB, bA)\n        else:\n            if ds.find_set(aA) == ds.find_set(bB):\n                return 0\n            ds.union(aA, bA)\n            ds.union(aB, bB)\n    return pow(2, (ds.num // 2) - 1, 10**9 + 7)\n\n\nprint(solve())\n'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 17263