import collections
from typing import Counter


N, M = map(int, input().split())
A: tuple = ()
B: tuple = ()
if M:
    A, B = zip(*(map(int, input().split()) for _ in range(M)))


G: list = [[] for _ in range(N)]

for i in range(M):
    G[A[i] - 1].append(B[i] - 1)
    G[B[i] - 1].append(A[i] - 1)


q: collections.deque = collections.deque()
v: set = set()
d: Counter = Counter()
c: Counter = Counter()

q.append(0)
v.add(0)
d[0] = 0
c[0] = 1


while q:
    i = q.popleft()
    for nx in G[i]:
        if nx not in v:
            q.append(nx)
            v.add(nx)
            d[nx] = d[i] + 1
            c[nx] = c[nx] + c[i]
        elif d[nx] == d[i] + 1:
            c[nx] = c[nx] + c[i]
        c[nx] %= 10**9 + 7

print(c[N - 1])
