Problem: You are given a directed graph of n vertices and m edges. Vertices are numbered from 1 to n. There is a token in vertex 1.

The following actions are allowed: 

  * Token movement. To move the token from vertex u to vertex v if there is an edge u → v in the graph. This action takes 1 second. 
  * Graph transposition. To transpose all the edges in the graph: replace each edge u → v by an edge v → u. This action takes increasingly more time: k-th transposition takes 2^{k-1} seconds, i.e. the first transposition takes 1 second, the second one takes 2 seconds, the third one takes 4 seconds, and so on. 



The goal is to move the token from vertex 1 to vertex n in the shortest possible time. Print this time modulo 998 244 353.

Input

The first line of input contains two integers n, m (1 ≤ n, m ≤ 200 000).

The next m lines contain two integers each: u, v (1 ≤ u, v ≤ n; u ≠ v), which represent the edges of the graph. It is guaranteed that all ordered pairs (u, v) are distinct.

It is guaranteed that it is possible to move the token from vertex 1 to vertex n using the actions above.

Output

Print one integer: the minimum required time modulo 998 244 353.

Examples

Input


4 4
1 2
2 3
3 4
4 1


Output


2


Input


4 3
2 1
2 3
4 3


Output


10

Note

The first example can be solved by transposing the graph and moving the token to vertex 4, taking 2 seconds.

The best way to solve the second example is the following: transpose the graph, move the token to vertex 2, transpose the graph again, move the token to vertex 3, transpose the graph once more and move the token to vertex 4.

Solution (in PYTHON3):

Solution:
#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase

pow2 = [1]
for i in range(30):
    pow2.append(pow2[-1] * 2)

class distance(object):
    def __init__(self, val1: int,val2: int):
        self.val1 = val1
        self.val2 = val2

    def __repr__(self):
        return f'Node value: {self.val1, self.val2}'

    def __lt__(self, other):
        a = self.val1
        b = self.val2
        c = other.val1
        d = other.val2
        if a == c and b < d:
            return True
        elif a == c and b >= d:
            return False
        elif a < c and c >= 30:
            return True
        elif a > c and a >= 30:
            return False
        elif pow2[a] + b < pow2[c] + d:
            return True
        elif pow2[a] + b >= pow2[c] + d:
            return False
        else:
            return False

class distance2(object):
    def __init__(self, val1: int,val2: int):
        self.val1 = val1
        self.val2 = val2

    def __repr__(self):
        return f'Node value: {self.val1, self.val2}'

    def __lt__(self, other):
        a = self.val1
        b = self.val2
        c = other.val1
        d = other.val2
        if a == c and b < d:
            return True
        elif a == c and b >= d:
            return False
        elif a < c:
            return True
        elif a > c:
            return False
        else:
            return False

from heapq import heappush, heappop

def main():
    MOD = 998244353
    n,m = map(int,input().split())
    graph = []
    for _ in range(n):
        graph.append([])
        graph.append([])
    for _ in range(m):
        u,v = map(int,input().split())
        graph[2 * u - 2].append(2 * v - 2)
        graph[2 * v - 1].append(2 * u - 1)
    for i in range(n):
        graph[2 * i].append(2 * i + 1)
        graph[2 * i + 1].append(2 * i)
    INF = 10 ** 9
    dist = [distance(INF,INF)] * (2 * n)
    dist[0] = distance(0,0)
    node = [(dist[0],0)]
    isVisited = [False] * (2 * n)
    while node:
        dista, curV = heappop(node)
        if isVisited[curV]:
            continue
        isVisited[curV] = True
        for newV in graph[curV]:
            if (curV - newV) % 2 == 0:
                newDist = distance(dist[curV].val1, dist[curV].val2 + 1)
                if newDist < dist[newV]:
                    dist[newV] = newDist
                    heappush(node,(newDist,newV))
            else:
                newDist = distance(dist[curV].val1 + 1, dist[curV].val2)
                if newDist < dist[newV]:
                    dist[newV] = newDist
                    heappush(node,(newDist,newV))
    dist1 = min(dist[2 * n - 1],dist[2 * n - 2])
    dist = [distance2(INF,INF)] * (2 * n)
    dist[0] = distance2(0,0)
    node = [(dist[0],0)]
    isVisited = [False] * (2 * n)
    while node:
        dista, curV = heappop(node)
        if isVisited[curV]:
            continue
        isVisited[curV] = True
        for newV in graph[curV]:
            if (curV - newV) % 2 == 0:
                newDist = distance2(dist[curV].val1, dist[curV].val2 + 1)
                if newDist < dist[newV]:
                    dist[newV] = newDist
                    heappush(node,(newDist,newV))
            else:
                newDist = distance2(dist[curV].val1 + 1, dist[curV].val2)
                if newDist < dist[newV]:
                    dist[newV] = newDist
                    heappush(node,(newDist,newV))
    dist2 = min(dist[2 * n - 1],dist[2 * n - 2])
    dist2N = distance(dist2.val1,dist2.val2)
    if dist1 < dist2N:
        print((pow(2,dist1.val1,MOD) + dist1.val2 - 1) % MOD)
    else:
        print((pow(2,dist2N.val1,MOD) + dist2N.val2 - 1) % MOD)
                

# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()