@staticmethod
def c_2():
    (n, a, b, m, *xy) = map(int, sys.stdin.read().split())
    a -= 1
    b -= 1
    g = GeometryTopology.Graph()
    for (x, y) in zip(*([iter(xy)] * 2)):
        x -= 1
        y -= 1
        g.add_edge(x, y, weight=1)
        g.add_edge(y, x, weight=1)
    (dist, paths) = g.dijkstra(a, paths_cnt=True, mod=MOD)
    print(paths[b])
@staticmethod
def c_2():
    (n, a, b, m, *xy) = map(int, sys.stdin.read().split())
    a -= 1
    b -= 1
    g = GeometryTopology.Graph()
    for (x, y) in zip(*([iter(xy)] * 2)):
        x -= 1
        y -= 1
        g.add_edge(x, y, weight=1)
        g.add_edge(y, x, weight=1)
    (dist, paths) = g.dijkstra(a, paths_cnt=True, mod=MOD)
    print(paths[b])