Harryxun/stf_run huggingface dataset:
#n>=25なら鳩ノ巣で0
#2人以上居るdは一意
#あとはしらみつぶし

n = int(input())
if n>=25:
    print(0)
    exit()

d = list(map(int, input().split( )))
if 0 in d:##
    print(0)
    exit()
d.append(0)
dic = {}

for di in d:
    if di in dic:
        dic[di] += 1
    else:
        dic[di]= 1
solo = []
times = []
for di in dic:
    if dic[di]==1:#di=0はここに入る
        solo.append(di)
    elif dic[di]==2:
        times.append(di)
        times.append(24-di)
    else:
        print(0)
        exit()
        
ans = 0
m = len(solo)
bit = 1<<m

for i in range(bit):
    times2 = []
    for t in times:
        times2.append(t)
    for j in range(m):
        if i>>j&1:
            times2.append(solo[j])
        elif solo[j]:
            times2.append(24-solo[j])
    times2.sort()
    dif = 24
    if len(time2)==1:###
        print(0)
        exit()
    #print(times2)

    for k in range(len(times2)-1):
        dif = min(dif,times2[k+1]-times2[k])
    ans = max(ans,dif)
print(ans)

### FIXED CODE ###

#n>=25なら鳩ノ巣で0
#2人以上居るdは一意
#あとはしらみつぶし

n = int(input())
if n>=25:
    print(0)
    exit()

d = list(map(int, input().split( )))
if 0 in d:##
    print(0)
    exit()
d.append(0)
dic = {}

for di in d:
    if di in dic:
        dic[di] += 1
    else:
        dic[di]= 1
solo = []
times = []
for di in dic:
    if dic[di]==1:#di=0はここに入る
        solo.append(di)
    elif dic[di]==2:
        times.append(di)
        if di!=12:
            times.append(24-di)
        else:
            print(0)
            exit()
    else:
        print(0)
        exit()
        
ans = 0
m = len(solo)
bit = 1<<m

for i in range(bit):
    times2 = []
    for t in times:
        times2.append(t)
    for j in range(m):
        if i>>j&1:
            times2.append(solo[j])
        else:####???
            times2.append(24-solo[j])
    times2.sort()
    dif = 24
    if len(times2)==1:###
        print(0)
        exit()
    #print(times2)

    for k in range(len(times2)-1):
        dif = min(dif,times2[k+1]-times2[k])
    dif = min(dif,times2[0] + 24 - times2[-1])
    ans = max(ans,dif)
print(ans)
n = int(input())
s = [input() for i in range(2)]
a = ""
for i in s:
    a = a + i
print(a)

### FIXED CODE ###

n = int(input())
s = input().split(" ")
b = list(s[0])
c = list(s[1])
a = ""
for i in range(n):
    a = a + b[i] + c[i]
print(a)
#coding: UTF-8
import math

p = list(map(int, input().split()))
dis = math.sqrt((p[2] - p[0]) + (p[3] - p[1]))

print(dis)


### FIXED CODE ###

#coding: UTF-8
import math

p = list(map(float, input().split()))
# dis = math.sqrt(pow((abs(p[2]) - abs(p[0])), 2) + pow((abs(p[3]) - abs(p[1])), 2))
dis = math.sqrt(pow((p[2] - p[0]), 2) + pow((p[3]) - (p[1]), 2))

print(round(dis, 8))
X, N = map(int,input().split())
if N == 0:
    print(X)
    exit()
else:
    P = list(map(int,input().split()))
L = [i for i in range(0,101) if i not in P]

if X in L:
    ANS = X
else:
    L.append(X)
    L = sorted(L)
    n = L.index(X)
    l = len(L) - 1


    if (0 < n < l):
        if (L[n+1]-L[n] < L[n] - L[n-1]):
            ANS = L[n+1]
        else:
            ANS = L[n - 1]

print(ANS)

### FIXED CODE ###

X, N = map(int,input().split())
if N == 0:
    print(X)
    exit()
else:
    P = list(map(int,input().split()))
L = [i for i in range(0,102) if i not in P]

if X in L:
    ANS = X
else:
    L.append(X)
    L = sorted(L)
    n = L.index(X)
    l = len(L) - 1


    if (0 < n < l):
        if (L[n+1]-L[n] < L[n] - L[n-1]):
            ANS = L[n+1]
        else:
            ANS = L[n - 1]
    elif (n == l):
        ANS = L[l - 1]

print(ANS)
N = int(input())

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

L = make_divisors(N)
l = len(L)
if l % 2 == 0:
    a1 = str(L[l // 2] - 1)
    a2 = str(L[l // 2])
    print(max(len(a1), len(a2)))
else:
    a1 = str(L[l // 2 - 1])
    a2 = str(L[l // 2])
    a3 = str(L[l // 2 + 1])
    print(max(len(a1), len(a2), len(a3)))


### FIXED CODE ###

N = int(input())
n = 10
for A in range(1, 100001):
    if N % A != 0:
        continue
    B = int(N / A)
    a = len(str(A))
    b = len(str(B))
    m = max(a, b)
    n = min(n, m)
print(n)
A1, A2, A3 = map(input().split(), int)

print('win' if A1+A2+A3 <= 21 else 'bust')

### FIXED CODE ###

A1, A2, A3 = map(int, input().split())
 
print('win' if A1+A2+A3 <= 21 else 'bust')
N = int(input())
if N%sum(list(str(N))) == 0:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

N = int(input())
if N % sum([int(i) for i in list(str(N))]) == 0:
    print("Yes")
else:
    print("No")
x = split(input()," ")
for i in range(len(x)):
  if int(x[i]) >= int(x[i-1]) and int(x[i]) >= int(x[i+1]):
    print (10*int(x[i])+int(x[i-1])+int(x[i+1]))

### FIXED CODE ###

A,B,C = map(int, input().split())
if A >= B and A >= C:
  print(A*10+B+C)
elif B >= A and B >= C:
  print(B*10+A+C)
else:
  print(C*10+A+B)
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int

def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

N = 10**5
g1 = [1, 1]
g2 = [1, 1]
inv = [0, 1]

for i in range(2, N+1):
    g1.append((g1[-1] * i) % MOD)
    inv.append((-inv[MOD % i] * (MOD//i)) % MOD)
    g2.append((g2[-1] * inv[-1]) % MOD)

def solve(N: int, M: int, K: int):
    ans = 0
    for i in range(1, M):
        ans += i * N**2 * (M-i)
        ans %= MOD
    for i in range(1, N):
        ans += i * M**2 * (N-i)
        ans %= MOD
    ans *= cmb(N*M-2, K-2, MOD)
    ans %= MOD
    print(ans)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, M, K)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int

def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

N = 2*10**5
g1 = [1, 1]
g2 = [1, 1]
inv = [0, 1]

for i in range(2, N+1):
    g1.append((g1[-1] * i) % MOD)
    inv.append((-inv[MOD % i] * (MOD//i)) % MOD)
    g2.append((g2[-1] * inv[-1]) % MOD)

def solve(N: int, M: int, K: int):
    ans = 0
    for i in range(1, M):
        ans += i * N**2 * (M-i)
        ans %= MOD
    for i in range(1, N):
        ans += i * M**2 * (N-i)
        ans %= MOD
    ans *= cmb(N*M-2, K-2, MOD)
    ans %= MOD
    print(ans)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, M, K)

if __name__ == '__main__':
    main()
N=int(input())
S=input()
n=N//2
for i in range(m):
  if S[i]!=S[n+i]:
	print('No')
else:
  print('Yes')

### FIXED CODE ###

N=int(input())
S=input()
if N%2==1:
  print('No')
  exit()
n=N//2
for i in range(n):
  if S[i]!=S[n+i]:
    print('No')
    break
else:
  print('Yes')
a,b,c= map(str, input().split())
print("{}{}{}".format(a,b,c).count("1"))

### FIXED CODE ###

s = str(input().split())
print(s.count("1"))
import fractions
A, B = map(int, input().split())
x = A * B // gcd(A, B)
print(x)


### FIXED CODE ###

import fractions
a, b = map(int, input().split())
print(a * b // fractions.gcd(a, b))
N = int(input())
if N == 1:
  print("Hallo World")
  else:
    A, B = [int(x) for x in input()]
    print(A+B)
    
    

### FIXED CODE ###

#! /usr/bin/env python3
# -*- coding: utf-8 -*-
N = int(input())
if N == 1:
    print('Hello World')
else:
    A,B = [int(input()),int(input())]
    print(A +B)
S = str(input())
cnt1=0
cnt2=0
for i in range(len(S)):
    if i==0:
        list1=S[0]
        cnt1+=1
    elif i==1:
        if S[i]==list1:
            cnt1+=1
        else:
            list2=S[i]
            cnt2+=1
    else:
        if S[i]==list1:
            cnt1+=1
        elif S[i]==list2:
            cnt2+=1
        else:
            pass
if cnt1==2 and cnt2==2:
    print('Yes')
else:
    print('No')
#print(cnt1,cnt2)

### FIXED CODE ###

S = str(input())
s = list(S)
s.sort()
if s[0]==s[1] and s[2]==s[3] and s[1]!=s[2]:
    print('Yes')
else:
    print('No')
#ABC063C
N = int(input())
s = [int(input()) for _ in range(N)]
ans = -1
s.sort()
for _ in range(N+1):
    ans = sum(s)
    if ans % 10 != 0:
        break
    elif len(s) == 0:
        ans = 0
        break
    elif len(s) >= 2:
        for i in range(1, len(s)):
            if (ans - s[0])%10 == 0 and (ans - s[i])%10 != 0:
                s.pop(i)
                del_ok = True
        if not del_ok:
            s.pop(0)
    else:
        s.pop(0)
print(ans)

### FIXED CODE ###

#ABC063C
N = int(input())
s = [int(input()) for _ in range(N)]
ans = -1
s.sort()
for _ in range(N+1):
    ans = sum(s)
    if ans % 10 != 0:
        break
    elif len(s) == 0:
        ans = 0
        break
    elif len(s) >= 2:
        del_ok = False
        for i in range(1, len(s)):
            if s[0]%10 == 0 and s[i]%10 != 0:
                s.pop(i)
                del_ok = True
                break
        if not del_ok:
            s.pop(0)
    else:
        s.pop(0)
print(ans)
import sys
sys.setrecursionlimit(10000)

def search_max_gcd(M, possible):
    if possible == 1:
        return 1
    elif (M % possible) == 0:
        return possible
    else:
        return search_max_gcd(M, possible-1)

def main():
    N, M = map(int, input().split())
    first_possible = M//N
    print(search_max_gcd(M, first_possible))

main()

### FIXED CODE ###

from math import *

def main():
    N, M = map(int, input().split())
    if N==1:
        print(M)
        return
    special_value = M//N
    divisor_set = set(i for i in range(1, (int(sqrt(M)) + 1)) if (M % i == 0))
    divisor_set = divisor_set.union(M/j for j in divisor_set)
    print(int(max([i for i in divisor_set if special_value >= i])))
    return

main()
import numpy as np
h, w = map(int, input().split())
s = np.array([list(input()) for _ in range(h)])
w1, w2 = np.array(["."]*w), np.array(["."]*(h+2))
s = np.hstack((w1, s))
s = np.hstack((s, w1))
s = np.vstack((w2.reshape(len(w2),1), s))
s = np.vstack((s, w2.reshape(len(w2),1)))
dx, dy = [1, 0, -1, 0], [0, 1, 0, -1]
for i in range(1, h+1, 1):
    for j in range(1, w+1, 1):
        now = s[i][j]
        c = 0
        if now == ".":
            continue
        for d in range(4):
            x = j + dx[d]
            y = i + dy[d]
            if now == s[y][x]:
                c += 1
        if c == 0:
            print("No")
            exit()
print("Yes")

### FIXED CODE ###

import numpy as np
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
s = np.array(s)
out = "Yes"
for i in range(h):
    for j in range(w):
        if s[i][j] == ".":
            continue
        if i == 0 and j == 0:
            up = s[i][j]
            down = s[i + 1][j]
            left = s[i][j]
            right = s[i][j + 1]
        elif i == 0 and j == w-1:
            up = s[i][j]
            down = s[i + 1][j]
            left = s[i][j - 1]
            right = s[i][j]
        elif i == h-1 and j == 0:
            up = s[i - 1][j]
            down = s[i][j]
            left = s[i][j]
            right = s[i][j + 1]
        elif i == h-1 and j == w-1:
            up = s[i - 1][j]
            down = s[i][j]
            left = s[i][j - 1]
            right = s[i][j]
        elif i == 0 and j != 0 and j != w-1:
            up = s[i][j]
            down = s[i + 1][j]
            left = s[i][j - 1]
            right = s[i][j + 1]
        elif i == h-1 and j != 0 and j != w-1:
            up = s[i - 1][j]
            down = s[i][j]
            left = s[i][j - 1]
            right = s[i][j + 1]
        elif j == 0 and i !=  0 and i != h-1:
            up = s[i - 1][j]
            down = s[i + 1][j]
            left = s[i][j]
            right = s[i][j + 1]
        elif j == w-1 and i != 0 and i!= h-1:
            up = s[i - 1][j]
            down = s[i + 1][j]
            left = s[i][j - 1]
            right = s[i][j]
        else:
            up = s[i-1][j]
            down = s[i+1][j]
            left = s[i][j-1]
            right = s[i][j+1]
        if s[i][j] != up and s[i][j] != down and s[i][j] != left and s[i][j] != right:
            out = "No"
print(out)
import sys
sys.setrecursionlimit(10000000)

def neighbor(N, edges):
    neighbor_list = [[] for _ in range(N)]
    for i in range(N):
        for vs in edges:
            if i + 1 in vs: # vsは頂点i+1が含まれるedge
                neighbor_list[i] += vs
        neighbor_list[i] = list(set(neighbor_list[i]))
        neighbor_list[i].remove(i + 1)
        
    return neighbor_list

def neighbor2(N, edges):
    nlist = neighbor(N, edges)
    nneighbor_list = [[] for _ in range(N)]
    for i in range(N):
        nneighbor_list[i] += nlist[i]
        for e in nlist[i]:
            nneighbor_list[i] += nlist[e - 1]
        nneighbor_list[i] = list(set(nneighbor_list[i]))
        nneighbor_list[i].remove(i + 1)
    return nneighbor_list
        
        
def combination(N, K, nnlist):
    combi = 1
    clist = [False]*N
    for v in range(N):
        print(combi)
        combi *= (K - len([t for t in nnlist[v] if clist[t-1]]))
        clist[v] = True
    return combi

def paint(N, K, nlist, nnlist, clist, vlist, combi):
    vlist_next = []
    for v in vlist:
        #nnlistの中で塗られている頂点の数を数え、色候補数Kから引く
        combi *= (K - len([t for t in nnlist[v - 1] if clist[t - 1]])) 
        clist[v - 1] = True #頂点vを塗る
        vlist_next += [t for t in nlist[v - 1] if not clist[t - 1]]
    return combi, vlist_next, clist


if __name__ == '__main__':
    N, K = map(int, input().split())
    edges = [None]*(N-1)
    
    for i in range(N-1):
        edges[i] = list(map(int, input().split()))
    
    nlist = neighbor(N, edges)
    nnlist = neighbor2(N, edges)
    
    vlist_next = [1]
    combi = 1
    clist = [False]*N
    for i in range(N):
        combi, vlist_next, clist = paint(N, K, nlist, nnlist, clist=clist, vlist=vlist_next, combi=combi)
        if len(vlist_next) == 0:
            break
    
    print(combi%1000000007)

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

def neighbor(N, edges):
    neighbor_list = [[] for _ in range(N)]
    for a, b in edges:
        neighbor_list[a-1] += [b-1]
        neighbor_list[b-1] += [a-1]
        
    return neighbor_list


def paint(K, nlist, now_num, from_num, case_num):
        mod = 1000000007
        if  from_num == -1:
            can_use_color = K - 1
        else:
            can_use_color = K - 2
        
        if len(nlist[now_num]) - 1 > can_use_color:
            return 0
        
        for child in nlist[now_num]:
            if child == from_num:
                continue
            else:
                case_num *= can_use_color
                can_use_color -= 1
                case_num %= mod
        
        for child in nlist[now_num]:
            if child == from_num:
                continue
            else:
                case_num = paint(K, nlist, child, now_num, case_num)
        return case_num%mod
            

if __name__ == '__main__':
    N, K = map(int, input().split())
    edges = [None]*(N-1)
    
    for i in range(N-1):
        edges[i] = list(map(int, input().split()))
    
    nlist = neighbor(N, edges)


    print(paint(K, nlist, 0, -1, K))
import numpy as np

N = int(input())
A = list(map(int,input().split()))

ans = np.zeros(N)

for i in range(N):
    ans[A[i]-1] = i+1

for i in range(N):
    print(int(ans[i]), end=' ')

### FIXED CODE ###

N = int(input())
ans = 0

if (N%2 == 0):
    ans = 0.5
else:
    ans = (N+1)/2/N

print(ans)
N, M = map(int, input().spit())
A = [input() for _ in range(M)]

s = sum(A)
ans = -1
if N >= s: ans = N - s
print(ans)

### FIXED CODE ###

N, M = map(int, input().split()) 
A = list(map(int, input().split()))
 
# N-sum(A)が残り日数である
s = sum(A)
ans = -1
if N >= s: ans = N - s
print(ans)
mod=10**9+7
n=int(raw_input())
t=map(int,raw_input().split())
a=map(int,raw_input().split())

if t[n-1]!=a[0]:
    print(0)
    exit()

ans=1
for i in xrange(n):
    if i==0 or i==n-1 or t[i]>t[i-1]:
        if a[i]<t[i] and a[i]==a[i+1]:
            print(0)
            exit()
        elif a[i]!=t[i] and a[i]!=a[i+1]:
            print(0)
            exit()
        continue
    else:
        if t[i]==a[i]:
            if a[i]==a[i+1]:
                ans=(ans*t[i])%mod
        elif t[i]>a[i]:
            if a[i]==a[i+1]:
                ans=(ans*a[i])%mod
        elif a[i]>t[i]:
            if a[i]==a[i+1]:
                ans=(ans*t[i])%mod
            else:
                print(0)
                exit()
print(ans%mod)

### FIXED CODE ###

mod=10**9+7
n=int(raw_input())
t=map(int,raw_input().split())
a=map(int,raw_input().split())

if t[n-1]!=a[0]:
    print(0)
    exit()

ans=1
for i in xrange(n):
    if i==0 or i==n-1:
        continue
    elif t[i]>t[i-1]:
        if a[i]<t[i] and a[i]==a[i+1]:
            print(0)
            exit()
        elif a[i]!=t[i] and a[i]!=a[i+1]:
            print(0)
            exit()
    else:
        if t[i]==a[i]:
            if a[i]==a[i+1]:
                ans=(ans*t[i])%mod
        elif t[i]>a[i]:
            if a[i]==a[i+1]:
                ans=(ans*a[i])%mod
        elif a[i]>t[i]:
            if a[i]==a[i+1]:
                ans=(ans*t[i])%mod
            else:
                print(0)
                exit()
print(ans%mod)
n = int(input())
no = n
list1 = list(map(int, input().split()))
# for i in range(n):
#     m = int(input())
#     list1.append(m)
# print(list1)
if 1 not in list1:
    print("-1")
else:
    for i in range(len(list1)):
        if list1[i] is not 1:
            pass
        else:
            # print("The location where i hits 1 is:",i)
            a = i
            no = no -1
            increasingshit = 2
            break
    list2 = []
    maxno = max(list1)
    # print("Max of all inputs is:",maxno)
    # print("now increasingshit is",increasingshit)

    def A(a):
        global increasingshit
        global no
        for j in range(a,len(list1)):
            if list1[j] == increasingshit:
                no = no - 1
                increasingshit = increasingshit + 1
                a = j
                A(a)
            else:
                pass
    A(a)
    print(no)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
ans = 0
cnt = 1
for x in a:
  if x == cnt:
    cnt += 1
  else:
    ans += 1
if ans == n:
  print(-1)
else:
  print(ans)
def main():
    from itertools import accumulate as ac
    from bisect import bisect_left as bl
    from bisect import bisect_right as br
    from sys import stdin
    input=stdin.readline

    def check(k):
        dist=a[-k-1]-ini
        if dist<0:
            dist=abs(dist)
            return k>=br(a,ini+dist)-bl(a,ini-dist)-1
        else:
            return k>=br(a,ini+dist)-bl(a,ini-dist)
    
    n,q=map(int,input().split())
    nn=n//2+1
    a=list(map(int,input().split()))
    x=[int(input()) for _ in [0]*q]
    ix=sorted([[i,j] for i,j in enumerate(x)],key=lambda x:x[1])
    ans=[0]*n
    aac=[0]+list(ac(a))
    aac2=[0]+list(ac(a[(n+1)%2::2]))
    k=nn

    for i,ini in ix:
        l=1
        u=k
        while l+1<u:
            med=(l+u)//2
            if check(med):u=med
            else:l=med+1
        if check(l):k=l
        else:k=u
        ans[i]=aac[-1]-aac[-k-1]+aac2[-k-1]
    for i in ans:
        print(i)
main()

### FIXED CODE ###

def main():
    from itertools import accumulate as ac
    from bisect import bisect_left as bl
    from bisect import bisect_right as br
    from sys import stdin
    input=stdin.readline

    def check(k):
        dist=a[-k-1]-ini
        if dist<0:
            dist=abs(dist)
            return k>=br(a,ini+dist)-bl(a,ini-dist)-1
        else:
            return k>=br(a,ini+dist)-bl(a,ini-dist)
    
    n,q=map(int,input().split())
    nn=n//2+1
    a=list(map(int,input().split()))
    x=[int(input()) for _ in [0]*q]
    ix=sorted([[i,j] for i,j in enumerate(x)],key=lambda x:x[1])
    ans=[0]*q
    aac=[0]+list(ac(a))
    aac2=[0]+list(ac(a[(n+1)%2::2]))
    k=nn

    for i,ini in ix:
        l=1
        u=k
        while l+1<u:
            med=(l+u)//2
            if check(med):u=med
            else:l=med+1
        if check(l):k=l
        else:k=u
        ans[i]=aac[-1]-aac[-k-1]+aac2[-k-1]
    for i in ans:
        print(i)
main()
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
x=0
for i in range (N-2):
  if A[i]+1 == A[i+1]:
    x= x+B[i]+C[A[i]]
  else:
    x= x+B[i]
print(x+B[N-1])

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
x=0
for i in range (N-1):
  if A[i]+1 == A[i+1]:
    x= x+B[i]+C[A[i]-1]
  else:
    x= x+B[i]
print(x+B[N-1])
def valid(i,j):
    if i>=0 and i<h and j>=0 and j<w:
        return 1
    return 0
def paths(i,j):

    if a[i][0][j]=='#' or valid(i,j)==0:
        return 0
    if i==h-1 or j==w-1:
        return 1
    else:
        if dp[i][j]==-1:
          dp[i][j]=paths(i+1,j)+paths(i,j+1)
          return dp[i][j]
        else:
            return dp[i][j]
    '''elif i==h-1 and j<w-1:
        if dp[i][j]==-1:
           dp[i][j]=paths(i,j+1)
           return dp[i][j]
        else:
            return dp[i][j]
    elif i<h-1 and j==w-1:
        if dp[i][j]==-1:
           dp[i][j]=paths(i+1,j)
           return dp[i][j]
        else:
            return dp[i][j]'''


h,w=map(int,input().split())
a=[[]for _ in range(h)]
m=1000000007
for i in range(h):
   a[i].extend(input().split())
dp=[[-1 for _ in range(w)]for _ in range(h)]
print(paths(0,0)%m)

### FIXED CODE ###

import sys
sys.setrecursionlimit(20000)

def paths(i, j):

    if i == h - 1 and j == w - 1:
        return 1
    if a[i][0][j] == '#':
        return 0
    if i < h - 1 and j < w - 1:
        if dp[i][j] == -1:
            dp[i][j] = paths(i + 1, j) + paths(i, j + 1)
            return dp[i][j]
        else:
            return dp[i][j]
    elif i == h - 1 and j < w - 1:
        if dp[i][j] == -1:
            dp[i][j] = paths(i, j + 1)
            return dp[i][j]
        else:
            return dp[i][j]
    elif i < h - 1 and j == w - 1:
        if dp[i][j] == -1:
            dp[i][j] = paths(i + 1, j)
            return dp[i][j]
        else:
            return dp[i][j]


h, w = map(int, input().split())
a = [[] for _ in range(h)]
m = 1000000007
for i in range(h):
    a[i].append(input())
dp = [[-1 for _ in range(1000)] for _ in range(1000)]
print(paths(0, 0) % m)