Harryxun/stf_run huggingface dataset:
n,x,m=map(int,input().split())

if x==0:
    print(0)
elif n<=m*3:
    asum=x
    ai=x
    for i in range(1,n):
        ai=(ai*ai)%m
        asum+=ai
    print(asum)
    
else:
    aa=[]
    ai=x
    icnt=0
    asum=0
    while not ai in aa:
        asum+=ai
        aa.append(ai)
        ai=(ai*ai)%m
        icnt+=1
    asum0=0
    ai0=x
    icnt0=0
    for i in range(m):
        asum0+=ai0
        ai0=(ai0*ai0)%m
        icnt0+=1
        if ai0==ai:
            break
    icntk=icnt-icnt0
    n0=n-1-icnt0
    nk=n0//icntk
    nr=n0%icntk
    asumk=asum-asum0
    asumr=0
    air=ai
    for i in range(nr):
        asumr+=air
        air=(air*air)%m
    asumr+=air
       
    ans=asum0+asumk*nk+asumr    
    print(ans)       
        


### FIXED CODE ###


n,x,m=map(int,input().split())

if x==0:
    print(0)
elif x==1:
    print(n)
elif m==1:
    print(0)
elif n<=m*2:
    asum=x
    ai=x
    for i in range(1,n):
        ai=(ai*ai)%m
        asum+=ai
    print(asum)
    
else:
    aa=[]
    ai=x
    icnt=0
    asum=0
    while not ai in aa:
        asum+=ai
        aa.append(ai)
        ai=(ai*ai)%m
        icnt+=1
    asum0=0
    ai0=x
    icnt0=0
    if ai!=x:
        for i in range(icnt+1):
            asum0+=ai0
            ai0=(ai0*ai0)%m
            icnt0+=1
            if ai0==ai:
                break
    icntk=icnt-icnt0
    if icntk==0:
#        print("0:",ai,asum,icnt,ai0,asum0,icnt0)
        icntk=1
        n0=n-1
        nk=n0//icntk
        nr=0
        asumk=ai0
        asumr=0
        ans=asum0+x*(n-icnt0)
        print(ans)       
    else:
#        print("1:",ai,asum,icnt,ai0,asum0,icnt0)
        n0=n-1-icnt0
        nk=n0//icntk
        nr=n0%icntk
        asumk=asum-asum0
        asumr=0
        air=ai
        for i in range(nr):
            asumr+=air
            air=(air*air)%m
        asumr+=air
       
        ans=asum0+asumk*nk+asumr    
        print(ans)
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

import resource,sys
resource.setrlimit(resource.RLIMIT_STACK,(2**29,-1))
sys.setrecursionlimit(10**6)

def dfs(u):
    global graph,vis
    vis.add(u)
    for i in graph[u]:
        if i not in vis:
            dfs(i)

n,m = ip()
graph = {i:[] for i in range(1,n+1)}
for i in range(m):
    a,b = ip()
    graph[a].append(b)
    graph[b].append(a)
for i in graph:
    graph[i] = list(set(graph[i]))
vis = set()
ans = -1
prev = 0
for i in range(1,n+1):
    if i not in vis:
        dfs(i)
        t = len(vis)
        ans = max(ans,t-prev)
        prev = t
print(ans)

### FIXED CODE ###

#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

import resource,sys
#resource.setrlimit(resource.RLIMIT_STACK,(2**29,-1))
sys.setrecursionlimit(10**6)

def dfs(u):
    global graph,vis
    vis.add(u)
    for i in graph[u]:
        if i not in vis:
            dfs(i)

n,m = ip()
graph = {i:[] for i in range(1,n+1)}
for i in range(m):
    a,b = ip()
    graph[a].append(b)
    graph[b].append(a)
for i in graph:
    graph[i] = list(set(graph[i]))
vis = set()
ans = -1
prev = 0
for i in range(1,n+1):
    if i not in vis:
        dfs(i)
        t = len(vis)
        ans = max(ans,t-prev)
        prev = t
print(ans)
from collections import deque


h, w = map(int, input().split())
hs, ws = set(range(h)), set(range(w))
a = []
d = deque([])
memo = [[None] * w for j in hs]
move = [[1, 0], [0, 1], [-1, 0], [0, -1]]
for i in hs:
    a.append(list(input()))
for i in hs:
    for j in ws:
        if a[i][j] == '#':
            d.append([i, j])
            memo[i][j] = 0


def d_list_update(d, hmax, wmax):
    dh, dw = d.popleft()
    for i, j in move:
        if (0 <= dh + i < hmax) and (0 <= dw + j < wmax) and not(memo[dh + i][dw + j]):
            memo[dh + i][dw + j] = memo[dh][dw] + 1
            d.append([dh + i, dw + j])
    return d


hw = set(range(h*w))
for i in hw:
    d = d_list_update(d, h, w)
    if not d:
        break
ans = max([max(e) for e in memo])
print(ans)

### FIXED CODE ###

from collections import deque
 
 
h, w = map(int, input().split())
hs, ws = set(range(h)), set(range(w))
d = deque()
memo = [[-1] * w for j in hs]
move = [[1, 0], [0, 1], [-1, 0], [0, -1]]
a = tuple(input() for _ in hs)
b = [[i, j] for i in hs for j in ws if a[i][j] == '#']
for i, j in b:
    d.append((i, j))
    memo[i][j] = 0
while d:
    dh, dw = d.popleft()
    for i, j in move:
        dhn, dwn = dh + i, dw + j
        if (0 <= dhn < h) and (0 <= dwn < w) and (memo[dhn][dwn] < 0):
            d.append((dhn, dwn))
            memo[dhn][dwn] = memo[dh][dw] + 1
ans = max([max(e) for e in memo])
print(ans)
s = input()
x,y = map(int,input().split())
count = 0
d = []
for i in range(len(s)):
    if s[i] == 'F':
        count += 1
    else:
        d.append(count)
        count = 0
if count != 0:
    d.append(count)

dx = [d[i] for i in range(len(d)) if i%2==0]
dy = [d[i] for i in range(len(d)) if i%2==1]
if len(dx) == 0:
    dx = [0]
if len(dy) == 0:
    dy = [0]
dpx = [[] for i in range(len(dx))]
dpx[0] = [dx[0]]
dpy = [[] for i in range(len(dy))]
dpy[0] = [dy[0],-dy[0]]
for i in range(len(dx)-1):
    trans = set()
    for j in range(len(dpx[i])):
        trans.add(dpx[i][j]+dx[i+1])
        trans.add(dpx[i][j]-dx[i+1])
    dpx[i+1] = trans
for i in range(len(dy)-1):
    trans = set()
    for j in range(len(dpy[i])):
        trans.add(dpy[i][j]+dy[i+1])
        trans.add(dpy[i][j]-dy[i+1])
    dpy[i+1] = trans
ans = (x in dpx[-1])&(y in dpy[-1])

if ans:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

s = input()
x,y = map(int,input().split())
count = 0
d = []
s = s.split('T')
d = [len(x) for x in s]

if len(d) == 0:
    d.append(0)
if len(d) == 1:
    d.append(0)
dpx = [d[0]]
dpy = [d[1],-d[1]]
for i in range(2,len(d)):
    di = d[i]
    trans = set()
    if i%2==0:
        for xj in dpx:
            trans.add(xj+di)
            trans.add(xj-di)
        dpx = list(trans)
    else:
        for yj in dpy:
            trans.add(yj+di)
            trans.add(yj-di)
        dpy = list(trans)
ans = (x in dpx)&(y in dpy)

if ans:
    print('Yes')
else:
    print('No')
n , x = map(int, input().split())
l = list(map(int, input().split()))
cnt = 0
s = 0
for i in range(l):
    s += i
    if s <= x:
        cnt += 1
    else:
        break

print(cnt)

### FIXED CODE ###

n , x = map(int, input().split())
l = list(map(int, input().split()))
tmp = [0] * (n + 1)
sum = 0
for i in range(n):
    sum += l[i]
    tmp[i + 1] = sum 

cnt = 0
for i in range(len(tmp)):
    if tmp[i] <= x:
        cnt += 1

print(cnt)
import numpy as np
n, k = map(int, input().split())
ans = n%k , (k-n%k)%k 
answer = np.min(ans)
print(answer)

### FIXED CODE ###

import numpy as np
n, k = map(int, input().split())
ans = n%k , (k-n%k)%k 
answer = np.min(ans)
print(answer)
import sys
import math
from collections import deque


def main():
    n_d_a = sys.stdin.readline().strip().split(' ')
    n, d, a = [int(s) for s in n_d_a]

    xh = [None] * n

    for i in range(n):
        x, h = [int(s) for s in sys.stdin.readline().strip().split(' ')]
        xh[i] = [x, h]
    xh.sort()

    cur = 0
    attack_rightmost_idx = [-1] * n
    for i in range(n):
        if cur == n:
            attack_rightmost_idx[i] = n-1
            continue
        attack_rightmost_idx[i] = cur
        x, h = xh[i]
        attack_rightmost = x + 2 * d
        while cur < n and xh[cur][0] <= attack_rightmost:
            attack_rightmost_idx[i] = cur
            cur += 1

    events = deque()
    total_damage = 0
    ans = 0
    for i in range(n):
        while events and events[0][0] <= i:
            total_damage += events[0][1]
            events.popleft()

        x, h = xh[i]

        remaining_life = h - total_damage
        if remaining_life <= 0:
            continue

        needed = math.ceil(remaining_life / a)
        ans += needed
        total_damage += needed * a
        events.append((attack_rightmost_idx[i]+1, - needed * a))

    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys

def main():
    h_and_n_s = sys.stdin.readline().strip().split(' ')
    h, n = [int(s) for s in h_and_n_s]
    a = [-1] * n
    b = [-1] * n

    # max_a = 0
    # ef_i = -1
    for i in range(n):
        a[i], b[i] = [int(s) for s in sys.stdin.readline().strip().split(' ')]
        # max_a = max(max_a, a[i])
        # if a[ef_i] / b[ef_i] < a[i] / b[i]:
        #     ef_i = i

    dp = [float('inf')] * (h+1)

    for point in range(h+1):
        for i in range(n):
            if point <= a[i]:
                dp[point] = min(dp[point], b[i])
                continue

            dp[point] = min(dp[point], dp[point-a[i]] + b[i])

    print(dp[h])


if __name__ == '__main__':
    main()
n,k = map(int,input().split())
h = list(map(int,input().split()))

h.sort()
for i in range(n):
    if h(i) < k:
        break
print(i)

### FIXED CODE ###

n,k = map(int,input().split())
h = list(map(int,input().split()))

c = 0

for i in range(n):
    if h[i] >= k:
        c += 1
print(c)
from heapq import heappush, heappop
from math import sqrt
EPS = 1e-10
xs, ys, xt, yt = map(int, raw_input().split())
n = input()
ps = [map(int, raw_input().split()) for i in xrange(n)]
def calc(x0, y0, r0, x1, y1, r1):
    v = (x0 - x1)**2 + (y0 - y1)**2
    if v <= (r0+r1)**2 + EPS:
        return 0.
    return sqrt(v) - r0 - r1
parent = range(n)
def root(x):
    if parent[x] != x:
        x = parent[x] = root(parent[x])
    return x
def unite(x, y):
    px = root(x)
    py = root(y)
    if px < py:
        parent[py] = px
    else:
        parent[px] = py
for i in xrange(n):
    x0, y0, r0 = ps[i]
    for j in xrange(i+1, n):
        if i == j: continue
        x1, y1, r1 = ps[j]
        if calc(x0, y0, r0, x1, y1, r1) < EPS:
            unite(i, j)
que = []
dist = [10**18+7]*n
for i in xrange(n):
    x, y, r = ps[i]
    d = dist[i] = calc(xs, ys, 0, x, y, r)
    heappush(que, (d, i))
while que:
    d, v = heappop(que)
    if dist[v] < d:
        continue
    x0, y0, r0 = ps[v]
    for t in xrange(n):
        if v == t: continue
        if root(v) == root(t) and d < dist[t]:
            dist[t] = d
            heappush(que, (d, t))
        else:
            x1, y1, r1 = ps[t]
            nd = calc(x0, y0, r0, x1, y1, r1)
            if d+nd < dist[t]:
                dist[t] = d+nd
                heappush(que, (d+nd, t))
ans = 10**18+7
for i in xrange(n):
    if cant[i]: continue
    x, y, r = ps[i]
    d = calc(xt, yt, 0, x, y, r) + dist[i]
    ans = min(ans, d)
print "%.010f" % ans


### FIXED CODE ###

from heapq import heappush, heappop
from math import sqrt
xs, ys, xt, yt = map(int, raw_input().split())
n = input()
ps = [map(int, raw_input().split()) for i in xrange(n)]
cant = [0]*n
for i in xrange(n):
    x0, y0, r0 = ps[i]
    for j in xrange(n):
        x1, y1, r1 = ps[j]
        if i == j or r0 > r1: continue
        if (x0 - x1)**2 + (y0 - y1)**2 <= (r1 - r0)**2:
            cant[i] = 1
            break

EPS = 1e-10
que = []
dist = [10**18+7]*n
def calc(x0, y0, r0, x1, y1, r1):
    v = (x0 - x1)**2 + (y0 - y1)**2
    if v <= (r0+r1)**2:
        return 0.
    return sqrt(v) - r0 - r1
for i in xrange(n):
    if cant[i]: continue
    x, y, r = ps[i]
    d = dist[i] = calc(xs, ys, 0, x, y, r)
    heappush(que, (d, i))
while que:
    d, v = heappop(que)
    if dist[v] < d:
        continue
    x0, y0, r0 = ps[v]
    for t in xrange(n):
        if v == t or cant[t]: continue
        x1, y1, r1 = ps[t]
        nd = calc(x0, y0, r0, x1, y1, r1)
        if d+nd < dist[t]:
            dist[t] = d+nd
            heappush(que, (d+nd, t))
ans = sqrt((xs - xt)**2 + (ys - yt)**2)
for i in xrange(n):
    if cant[i]: continue
    x, y, r = ps[i]
    d = calc(xt, yt, 0, x, y, r) + dist[i]
    ans = min(ans, d)
print "%.010f" % ans
c11,c12,c13=map(int,input().split())
c21,c22,c23=map(int,input().split())
c31,c32,c33=map(int,input().split())
for i in range(1,101):
    for j in range(1,101):
        if 

### FIXED CODE ###

c11,c12,c13=map(int,input().split())
c21,c22,c23=map(int,input().split())
c31,c32,c33=map(int,input().split())
if c11+c22+c33 == c12+c23+c31 == c13+c21+c32:
    print("Yes")
else:
    print("No")
import sys
ff = sys.stdin
while True:
  a,b = map(int,ff.readline().split())
  if (a == 0) and (b == 0):
  break
    if a < b :print(a,b)
    else:print(b,a)

### FIXED CODE ###

import sys
while True:
    a,b=map(int,sys.stdin.readline().split())
    if a==0 and b==0:
        break
    if a<b:print(a,b)
    else:print(b,a)
n,t=map(int,input().split())
c_t=[list(map(int,input().split())) for _ in range(n)]
ans=[]
for i in range(n):
    if c_t[i][1]<=t:
        ans.append(c_t[i][0])
print(min(ans))

### FIXED CODE ###

n,t=map(int,input().split())
c_t=[list(map(int,input().split())) for _ in range(n)]
ans=[]
for i in range(n):
    if c_t[i][1]<=t:
        ans.append(c_t[i][0])
print(min(ans) if sum(ans)>0 else "TLE")
N, M = map(int, input().split())
a = []
tmp = []
for i in range(N):
    tmp = list(map(str,input().split()))
    a.append(list(tmp[0]))

for i in range(N):
    for j in range(M):
        if a[i][j] == '#':
            if a[i][j - 1] != '#' and a[i - 1][j] != '#' and a[i][j + 1] != '#' and a[i + 1][j] != '#':
                print("No")
                exit()
        else:
            pass

print("Yes")

### FIXED CODE ###

H, W = map(int, input().split())
a = []
tmp = []
for i in range(H):
    tmp = list(map(str,input().split()))
    a.append(list(tmp[0]))

for i in range(H):
    for j in range(W):
        if a[i][j] == '#':
            if j - 1 >= 0 and a[i][j - 1] == "#":
                continue
            elif j + 1 < W and a[i][j + 1] == "#" :
                continue
            elif i + 1 < H and a[i + 1][j] == "#" :
                continue
            elif i - 1 >= 0 and a[i - 1][j] == "#":
                continue
            else:
                print("No")
                exit()
 
print("Yes")
num = [0,0,0]
num[0] = int(input())
num[1] = int(input())
num[2] = int(input())

num.sorted()

print(int(str(num[0]) + str(num[1])) + num[2])

### FIXED CODE ###

s = input()

num = list(s)

num.sort()
num.reverse()

print(int(num[0] + num[1]) + int(num[2]))
a,b=input().split()
c=a+b if b%a=0 b-a
print(c)

### FIXED CODE ###

a, b = map(int, input().split())
c = a+b if b % a == 0 else b-a
print(c)
N,i =map(int(),input().split())
print(N-i+1)

### FIXED CODE ###

N,i = map(int,input().split())
print(N-i+1)
a, b, c = map(int, input().split(" "))


for i in range(1, c):
    if (a * i) % b == c:
        print("YES")
        break
else:
    print("NO")

a* (任意の整数) % b = cとできるか？


### FIXED CODE ###

N, T = map(int, input().split(" "))
t = list(map(int, input().split(" ")))

shower = 0

for i in range(0, N-1):
    if t[i+1]-t[i] >= T:
        shower += T
    else:
        shower += t[i+1]-t[i]

shower += T
print(shower)
n = int(input())
a= map(int,input().split())
c = 1
if 0 in a:
    print(0)
else:
    for x in a:
        if x >10**18:
            print(-1)
            break
        else:
            z = x*c
            c = z
            if z >10**18:
                print(-1)
                break
print(z)

### FIXED CODE ###

n = int(input())
a= list(map(int,input().split()))
c = 1
if 0 in a:
    print(0)
else:
    for x in a:
        if x >10**18:
            print(-1)
            break
        else:
            z = x*c
            c = z
            if z >10**18:
                print(-1)
                break
    else:
        print(z)
N = int(input())
adj = [ [] for _ in range(N) ]
for _ in range(N-1):
  u,v,w = map(int,input().split())
  u -= 1
  v -= 1
  adj[u].append((v,w))
  adj[v].append((u,w))

color = [None] * N
def dfs(n,l):
  if l%2==0:
    color[n] = 1
  else:
    color[n] = 0

  for nei, nl in adj[n]:
    if color[nei] is not None:
      if (l+nl) % 2 == 0 and color[nei] != 1:
        return False
      if (l+nl) % 2 == 1 and color[nei] != 0:
        return False
    else:
      dfs(nei, l+nl)

  return True

for i in range(N):
  if color[i] is None:
    if not dfs(i,0):
      print(-1)
      exit()

for c in color: print(c)

### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)

N = int(input())
adj_list = { i: [] for i in range(N+1) }
for _ in range(N-1):
  u,v,w = map(int, input().split())
  adj_list[u].append([v,w])
  adj_list[v].append([u,w])

res = [None] * N
visited = [False] * (N+1)
def dfs(node, c, w):
  res[node-1] = c
  visited[node] = True

  for nei, nw, in adj_list[node]:
    if not visited[nei]:
      if (w+nw)%2 == 0:
        dfs(nei, 0, w+nw)
      else:
        dfs(nei, 1, w+nw)

dfs(1, 0, 0)
for r in res: print(r)
S = input()
S[0] = '2'
S[1] = '0'
S[2] = '1'
S[3] = '8'
print(for i in S) 

### FIXED CODE ###

S = input()
print('2018' + S[4:])
# coding:utf-8
import numpy as np

N = int(input())
A = [int(n) for n in input().split(' ')]
div_n = 10 ** 9 + 7
min_a = min(A)
lcm = A[0]

for a in A:
    lcm = np.lcm(lcm, a)

if min_a == lcm:
    print((1*N) % div_n)
else:
    stack = 0
    for a in A:
        stack += lcm // a
    print(stack % div_n)

### FIXED CODE ###

# coding:utf-8
from fractions import gcd

def calc_lcm(a, b):
    return (a * b) // gcd(a, b)

N = int(input())
A = [int(n) for n in input().split(' ')]
div_n = 10 ** 9 + 7
min_a = min(A)
lcm = A[0]

for a in A:
    lcm = calc_lcm(lcm, a)

if min_a == lcm:
    print((1*N) % div_n)
else:
    stack = 0
    for a in A:
        stack += lcm // a
    print(stack % div_n)
S=input()
if 1<=int(S[:2])<=12 and 13<=int(S[2:]) or int(S[2:])==0:
    print("MMYY")
elif 1<=int(S[2:])<=12 and 13<=int(S[:2]) or int(S[:2])==0:
    print("YYMM")
elif 1<=int(S[2:])<=12 and 1<=int(S[:2])<=12:
    print("AMBIGUOUS")2
elif 13<=int(S[2:]) or int(S[2:])==0 and 13<=int(S[:2]) or int(S[:])==0:
    print("NA")

### FIXED CODE ###

N,K=map(int,input().split())
S=input()
if S[K-1]=="A":
    ans=S[:K-1]+"a"+S[K:]
elif S[K-1]=="B":
    ans=S[:K-1]+"b"+S[K:]
if S[K-1]=="C":
    ans=S[:K-1]+"c"+S[K:]
print(ans)
def D_Lamp():
    h, w = map(int, input().split())
    S = [[0 for i in range(w)] for j in range(h)]
    for row in range(h):
        si = input()
        for col in range(w):
            if "." == si[col]:
                S[row][col] = 1
    S_row = calc_point_row(h,w,S)
    S_col = calc_point_col(h,w,S)
    # 
    num_max = 0
    for row in range(h):
        for col in range(w):
            s_num = S_row[row][col] + S_col[row][col] - 1
            num_max = max(num_max, s_num)
    print(num_max)
def calc_point_row(h,w,S):
    S_tmp = [[0 for i in range(w)] for j in range(h)]
    for row in range(h):
        sum_w = 0
        for col in range(w):
            if 1 == S[row][col]:
                sum_w += 1
            elif (sum_w == 0):
                S_tmp[row][col] = 0
            else:
                for x in range(sum_w):
                    S_tmp[row][col-x-1] = sum_w
                sum_w = 0
        if (sum_w == w):
            for x in range(sum_w):
                S_tmp[row][i] = sum_w
        elif (sum_w != 0):
            for x in range(sum_w):
                S_tmp[row][w-x-1] = sum_w
    return S_tmp
def calc_point_col(h,w,S):
    S_tmp = [[0 for i in range(w)] for j in range(h)]
    for col in range(w):
        sum_w = 0
        for row in range(h):
            if 1 == S[row][col]:
                sum_w += 1
            elif (sum_w == 0):
                S_tmp[row][col] = 0
            else:
                for x in range(sum_w):
                    S_tmp[row-x-1][col] = sum_w
                sum_w = 0
        if (sum_w == h):
            for x in range(sum_w):
                S_tmp[x][col] = sum_w
        elif (sum_w != 0):
            for x in range(sum_w):
                S_tmp[h-x-1][col] = sum_w
    return S_tmp

if __name__ == "__main__":
    D_Lamp()

### FIXED CODE ###

def D_Lamp():
    import numpy as np
    # input & init
    h, w = map(int, input().split())
    S = np.array([list(input()) for _ in range(h)]) == "."
    L = np.zeros((h,w), dtype=int)
    R = np.zeros((h,w), dtype=int)
    U = np.zeros((h,w), dtype=int)
    D = np.zeros((h,w), dtype=int)
    # calc row
    for row in range(h):
        D[row] =(D[row - 1] + 1) * S[row]
        U[-row - 1] = (U[-row] + 1) * S[-row -1]
    # calc col
    for col in range(w):
        R[:, col] = (R[:, col - 1] + 1) * S[:, col]
        L[:, -col - 1] = (L[:, -col] + 1) * S[:, -col-1]
    num_max = 0
    print(np.max(L+R+U+D) - 3)

if __name__ == "__main__":
    D_Lamp()
def noboru(i, a2, a1):
    if (i == 1):
        return a1
    elif (i == 2):
        return a2
    else:
        return noboru(i-1, a2+a1, a2)


def func(N, M, a):
    ans = 1
    if (a[0] == 1):
        ans *=1
    else:
        ans *= noboru(a[0]-1, 2, 1)
    if (M > 1):
        for i in range(1, M):
            if (a[i] == a[i-1]+1):
                return 0
            else:
                ans *= noboru(a[i] - a[i-1] -2, 2, 1)
    ans *= noboru(N - a[M-1] -1, 2, 1)
    return ans

N, M = map(int, input().split(" "))
a = [int(input()) for _ in range(M)]
#A_i = list(map(int, input().split(" ")))
#B_i = list(map(int, input().split(" ")))
print(func(N, M, a) % 1000000007)
#print(noboru(100, 2, 1))

### FIXED CODE ###

CONST = 1000000007

def noboru(n):
    a1 = 1
    a2 = 2
    ans = 0
    if (n == 0 or n == 1): return a1
    elif (n == 2): return a2
    else:
        for i in range(1, n-1):
            ans = a2 + a1
            a1 = a2
            a2 = ans
        return a2

def func(N, M, a):
    ans = 1
    pos = 0
    for i in range(M):
        if (pos == a[i]):
            return 0
        else:
            ans = (ans * noboru(a[i] - pos - 1)) % CONST
            pos = a[i] + 1
    ans = (ans * noboru(N - pos)) % CONST
    return ans

N, M = map(int, input().split(" "))
a = [int(input()) for _ in range(M)]
print(func(N, M, a))
import numpy as np
n = int(input())
lista = [int(e) for e in input().split()]
lista = np.array(lista)
ans = np.cumprod(lista)

if ans > 10**18:
    ans=-1

print(ans)

### FIXED CODE ###

n = int(input())
lista = [int(e) for e in input().split()]

if 0 in lista:
    ans = 0
else:
    ans = 1
    for i in lista:
        ans *= i
        if ans>10**18:
            ans = -1
            break

print(ans)
import numpy as np

N = int(input())
A_list = list(map(int, input().split()))
ans_list =np.ones(N)
A_list = np.array(A_list)

for i in range(N-1):
    for j in range(i+1,N):
        if A_list[i] %  A_list[j] == 0:
            ans_list[i] = 0
            if (A_list[j] %  A_list[i] == 0):
                ans_list[j] = 0
        elif(A_list[j] %  A_list[i] == 0):
            ans_list[j] = 0
print(int(np.sum(ans_list)))


### FIXED CODE ###

from sys import stdin
import numpy as np
input = stdin.readline

N = int(input())
A_list = list(map(int, input().split()))
# ans_list =np.ones(N)
# A_list = np.array(A_list)

# for i in range(N-1):
#     for j in range(i+1,N):
#         if A_list[i] %  A_list[j] == 0:
#             ans_list[i] = 0
#             if (A_list[j] %  A_list[i] == 0):
#                 ans_list[j] = 0
#         elif(A_list[j] %  A_list[i] == 0):
#             ans_list[j] = 0
# print(int(np.sum(ans_list)))
A_set = list(set(A_list))
maxA =  A_set[-1]
dp = [1] * (( 10 ** 6) + 1)

cntli = [0] * (( 10 ** 6) + 1)
unique =[]
for i in A_list:
    cntli[i] += 1
for i in range((( 10 ** 6) + 1)):
    if cntli[i] == 1:
        unique.append(i)

for elem in A_set:
    for i in range(2 * elem,  10 ** 6 + 1, elem):
        dp[i] = 0

ans = 0
for i in unique:
    if not (dp[i] == 0):
        ans += 1

print(ans)
a, b = map(int, input().split())
print({:.10f}.format(a/b))

### FIXED CODE ###

a, b = map(int, input().split())
print("{:.10f}".format(a/b))