Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
ans=0
tempi=[0]*n
tempj=[0]*n
for i in range(n):
  tempi[i]=a[i]+i+1
for i in range(n):
  tempj[i]=-a[i]+i+1
for i in range(n):
  ans=ans+tempj.count(tempi[i])
print(ans)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
ans=0
tempi=[0]*n
tempj=[0]*n
for i in range(n):
  tempi[i]=a[i]+i+1
for i in range(n):
  tempj[i]=-a[i]+i+1
import collections
tempid=collections.Counter(tempi)
tempjd=collections.Counter(tempj)
for k in tempid.keys():
  a=tempid[k]
  b=tempjd[k]
  ans=ans+a*b
print(ans)
### BUGGY CODE ###

import sys;input=sys.stdin.readline

n, q = map(int, input().split())
event = []
for _ in range(n):
    s, t, x = map(int, input().split())
    event.append((s-x-0.5, 1, x))
    event.append((t-x-0.5, -1, x))
for i in range(q):
    event.append((int(input()), 0, i))

event.sort()
stop = set()
ans={}
for t,e,x in event:
    if e > 0:
        stop.add(x)
    elif e < 0:
        stop.remove(x)
    else:
        if len(stop) > 0:
            ans[x] = min(stop)
        else:
            ans[x] = -1

for i in range(q):
    print(ans[i])

### FIXED CODE ###

import sys;input=sys.stdin.readline

n,q=map(int, input().split())
event=[]
for _ in range(n):
    s,t,x=map(int,input().split())
    event.append((s-x-0.5,1,x))
    event.append((t-x-0.5,-1,x))
for i in range(q):
    event.append((int(input()),0,i))

event.sort()
is_stop=False
stop=set()
minstop=float('inf')
ans=[-1]*q
for t,e,x in event:
    if e > 0:
        stop.add(x)
        if x<minstop:
            minstop=x
            is_stop=True
    elif e<0:
        stop.remove(x)
        if minstop==x:
            is_stop=False
    elif len(stop)>0:
        if not is_stop:
             minstop=min(stop)
             is_stop=True
        ans[x]=minstop

print('\n'.join(map(str, ans)))
### BUGGY CODE ###

S = str(input())
S= list(S)
switch = 0  
for i in range(len(S)):
    S[i] = int(S[i])
S_change = S
result = 0
count = 1
while len(S_change) >= 2 and count != 0:   
    S_list = S_change
    S_change = []
    count = 0
    switch = 0
    # print(S_list)
    for i in range(len(S_list)):
        if switch == 1:
            switch = 0
        elif i == len(S_list)-1:
            S_change.append(S_list[i])
        elif S_list[i] != S_list[i+1]:
            result = result +2
            count = count + 1
            switch = 1        
        else:
            S_change.append(S_list[i])
    # print(S_change)
print(result)

### FIXED CODE ###

S = str(input())
S= list(S)
switch = 0  
for i in range(len(S)):
    S[i] = int(S[i])
count_0 = 0
count_1 = 0
for i in range(len(S)):
    if S[i] == 0:
        count_0 = count_0 + 1
    else:
        count_1 = count_1 + 1
        
if count_0 > count_1:
    count = count_1
else:
    count = count_0
    
result = 2 * count
print(result)
### BUGGY CODE ###

import collections
N = int(input())
S = [input() for i in range(N)]
ans = collections.defaultdict(int)
for i in S:
  ans[i] += 1
  
max_list = [kv[0] for kv in ans.items() if kv[1] == max(ans.values())] 
max_list.sort()
for i in max_list:
  print(i)

### FIXED CODE ###

import collections
N = int(input())
S = [input() for i in range(N)]
ans = collections.defaultdict(int)
for i in S:
  ans[i] += 1
  
max_num = max(ans.values())
max_list = [kv[0] for kv in ans.items() if kv[1] == max_num] 
max_list.sort()
for i in max_list:
  print(i)
### BUGGY CODE ###

import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    D=[int(_) for _ in input().split()]
    M=int(input())
    T=[int(_) for _ in input().split()]

    for t in T:
        if t in D:
            D.remove(t)
        else:
            print("NO")
            break
    else:
        print("YES")

if __name__=='__main__':
    main()

### FIXED CODE ###

import sys
def input(): return sys.stdin.readline().rstrip()
from collections import Counter
def main():
    n=int(input())
    D=[int(_) for _ in input().split()]
    D_c=Counter(D)
    M=int(input())
    T=[int(_) for _ in input().split()]
    T_c=Counter(T)
    for t in T_c.items():
        if D_c[t[0]]<t[1]:
            print("NO")
            break
    else:
        print("YES")

if __name__=='__main__':
    main()
### BUGGY CODE ###

n = int(input())
an = [int(num)  for num in input().split()]

sum = 0
for i in range(len(an)):
  for j in range(i+1,len(an)):
    sum +=  an[i]*an[j]
print(sum%1000000007)

### FIXED CODE ###

n = int(input())
an = [int(num)  for num in input().split()]

an_total = sum(an)
answer = 0
for i in range(len(an)-1):
  an_total -= an[i]
  answer +=  an[i] * an_total
print(answer%1000000007)
### BUGGY CODE ###

import numpy as np


def main():
    H, W = map(int, input().split())
    A = np.zeros([H, W])
    for h in range(H):
        A[h, :] = list(map(lambda x: 1 if x == "#" else 0, input()))

    costs = np.zeros([H, W])
    dd = ((1, 0), (-1, 0), (0, 1), (0, -1))

    s = np.where(A == 1)
    s = np.array(s)
    len_s = s.shape[1]
    q = []
    for i in range(len_s):
        q.append((s[0, i], s[1, i]))

    moves = 0

    while q:
        qn = []
        moves += 1
        for x, y in q:
            for dx, dy in dd:
                nx, ny = int(x + dx), int(y + dy)
                if 0 <= nx < H and 0 <= ny < W:
                    if A[nx, ny] == 0:
                        costs[nx, ny] = moves
                        A[nx, ny] = 1
                        qn.append((nx, ny))

        q = qn

    print(int(np.max(costs)))


main()


### FIXED CODE ###

def main():
    H, W = map(int, input().split())
    field = [list(input()) for _ in range(H)]
    dd = ((1, 0), (-1, 0), (0, 1), (0, -1))

    q = []
    for i in range(H):
        for j in range(W):
            if field[i][j] == "#":
                q.append((i, j))
                field[i][j] = 0
    moves = 0

    while q:
        qn = []
        moves += 1
        for x, y in q:
            for dx, dy in dd:
                nx, ny = int(x + dx), int(y + dy)
                if 0 <= nx < H and 0 <= ny < W:
                    if field[nx][ny] == ".":
                        field[nx][ny] = moves
                        qn.append((nx, ny))

        q = qn

    m = []
    for i in range(H):
        m.append(max(field[i]))
    print(max(m))


main()
### BUGGY CODE ###

H, W = map(int, input().split())
A = []
for _ in range(H):
    A.append(list(map(int, input().split())))
B = []
C = []
for y in range(H):
    B.append(list(map(int, input().split())))
    C.append(list(abs(a-b) for (a, b) in zip(A[y], B[y])))
VMAX = 159*80+1
dp = [[[0] * VMAX for _ in range(W)] for _ in range(H)]
dp[0][0][C[0][0]] = 1
for y in range(H):
    for x in range(W):
        if y==0 and x==0:
            continue
        for v in range(VMAX):
            if y-1 >= 0 and dp[y-1][x][v]:
                dp[y][x][abs(v+C[y][x])] = 1
                dp[y][x][abs(v-C[y][x])] = 1
            if x-1 >= 0 and dp[y][x-1][v]:
                dp[y][x][abs(v+C[y][x])] = 1
                dp[y][x][abs(v-C[y][x])] = 1
ans = -1
for v in range(VMAX):
    if dp[-1][-1][v]:
        ans = v
        break
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline
H, W = map(int, input().split())
A = []
for _ in range(H):
    A.append(list(map(int, input().split())))
B = []
C = []
for y in range(H):
    B.append(list(map(int, input().split())))
    C.append(list(abs(a-b) for (a, b) in zip(A[y], B[y])))
VMAX = 80*159+1
dp = [[0 for _ in range(W)] for _ in range(H)]
dp[0][0] |= 1 << C[0][0]
for y in range(H):
    for x in range(W):
        if y==0 and x==0:
            continue
        if y-1 >= 0:
            dp[y][x] |= dp[y-1][x] << C[y][x]
            dp[y][x] |= dp[y-1][x] >> C[y][x]
            d = C[y][x]+1
            r = format(dp[y-1][x] & (2**d-1), '0'+str(d)+'b')
            r = r[::-1]
            dp[y][x] |= int(r, 2)
        if x-1 >= 0:
            dp[y][x] |= dp[y][x-1] << C[y][x]
            dp[y][x] |= dp[y][x-1] >> C[y][x]
            d = C[y][x]+1
            r = format(dp[y][x-1] & (2**d-1), '0'+str(d)+'b')
            r = r[::-1]
            dp[y][x] |= int(r, 2)
ans = -1
for v in range(VMAX):
    if dp[-1][-1] >> v & 1:
        ans = v
        break
print(ans)
### BUGGY CODE ###

import sys
readline = sys.stdin.buffer.readline

N, M = map(int, readline().split())
ans = []
append_ans = ans.append
graph = [[] for _ in range(N+1)]

for _ in range(M):
    a, b = map(int, readline().split())
    graph[a].append(b)
    graph[b].append(a)

root = 1
q = [root]
append_q = q.append
checked = [0] * (N + 1)
checked[root] = 1
order = []
append_order = order.append

while q:
    x = q.pop(0)
    for y in graph[x]:
        if checked[y]:
            continue
        append_ans(x)
        append_order(y-2)
        checked[y] = 1
        append_q(y)

if len(order) != N - 1:
    print('No')
else:
    print('Yes')
    for i in range(len(order)):
        j = order.index(i)
        print(ans[j])

### FIXED CODE ###

import sys
readline = sys.stdin.buffer.readline
read = sys.stdin.buffer.read

N, M = map(int, readline().split())
m = map(int, read().split())
AB = list(zip(m, m))
graph = [[] for _ in range(N+1)]
for a, b in AB:
    graph[a].append(b)
    graph[b].append(a)

root = 1
q = [root]
checked = [0] * (N + 1)
checked[root] = 1
order = []
D = [0 for _ in range(N+1)]
d = 0
while q:
    x = q.pop(0)
    d = D[x]
    for y in graph[x]:
        if checked[y]:
            continue
        D[y] = d + 1
        checked[y] = 1
        q.append(y)

ans = [0 for _ in range(N+1)]
for a, b in AB:
    d_a, d_b = D[a], D[b]
    if d_a < d_b:
        ans[b] = a
    elif d_a > d_b:
        ans[a] = b

print('Yes')
print('\n'.join(map(str, ans[2:])))
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import copy

# 整数の入力
n = int(input())

ninzu = []

for inpcnt in range(5):
    ninzu.append(int(input()))

toshi = [n,0,0,0,0,0]
next_toshi = copy.deepcopy(toshi)
time = 0

while toshi[5] != n:
    # print("toshi[0]:{},[1]:{},[2]:{},[3]:{},[4]:{},[5]:{}".format(toshi[0],toshi[1],toshi[2],toshi[3],toshi[4],toshi[5]))
    time += 1
    for i in range(len(toshi)-1):
        if toshi[i] != 0:
            if toshi[i] > ninzu[i]:
                next_toshi[i] = next_toshi[i] - ninzu[i]
                next_toshi[i+1] = toshi[i+1]  + ninzu[i]
            else:
                next_toshi[i] = next_toshi[i] - toshi[i]
                next_toshi[i+1] = toshi[i+1] + toshi[i] 
        # print("toshi[{}]:{},toshi[{}]:{}".format(i,next_toshi[i],i+1,next_toshi[i+1]))
    toshi = copy.deepcopy(next_toshi)
    # print("next_toshi[0]:{},[1]:{},[2]:{},[3]:{},[4]:{},[5]:{}".format(next_toshi[0],next_toshi[1],next_toshi[2],next_toshi[3],next_toshi[4],next_toshi[5]))
        
print(str(time))


### FIXED CODE ###

# -*- coding: utf-8 -*-
import copy
import math

# 整数の入力
n = int(input())

capa = []

capa=[int(input()) for i in range(5)]

# 各交通機関のうち、運べる人数が一番少ないものをベースとする
capa_min = min(capa)

ans = n//capa_min 

# if n <= capa_min:
#     amari = 0
# else:
amari = n % capa_min

# 人数が割り切れたら
if amari != 0:
    ans += 5
else:
    ans += 4
    
print (str(ans))



# 以下の処理だとタイムオーバーになるからNG
# toshi = [n,0,0,0,0,0]
# next_toshi = copy.deepcopy(toshi)
# time = 0

# while toshi[5] != n:
#     # print("toshi[0]:{},[1]:{},[2]:{},[3]:{},[4]:{},[5]:{}".format(toshi[0],toshi[1],toshi[2],toshi[3],toshi[4],toshi[5]))
#     time += 1
#     for i in range(len(toshi)-1):
#         if toshi[i] != 0:
#             if toshi[i] > capa[i]:
#                 next_toshi[i] = next_toshi[i] - capa[i]
#                 next_toshi[i+1] = toshi[i+1]  + capa[i]
#             else:
#                 next_toshi[i] = next_toshi[i] - toshi[i]
#                 next_toshi[i+1] = toshi[i+1] + toshi[i] 
#         # print("toshi[{}]:{},toshi[{}]:{}".format(i,next_toshi[i],i+1,next_toshi[i+1]))
#     toshi = copy.deepcopy(next_toshi)
#     # print("next_toshi[0]:{},[1]:{},[2]:{},[3]:{},[4]:{},[5]:{}".format(next_toshi[0],next_toshi[1],next_toshi[2],next_toshi[3],next_toshi[4],next_toshi[5]))
        
# print(str(time))
### BUGGY CODE ###

# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#import bisect# lower_bound etc
#import numpy as np
#from copy import deepcopy
#from collections import deque
import math

def run():
    N = int(input())
    for n in range(1, N+1):
        ret = 0
        val = int(math.sqrt(2 * n))
        for X in range(-val, val+1):
            for Y in range(-val, val+1):
                tmp1 = 2 * n - X ** 2 - Y ** 2
                if tmp1 >= 0 and math.sqrt(tmp1) == int(math.sqrt(tmp1)):
                    Z_ = int(math.sqrt(tmp1))
                    if Z_ != 0:
                        for k in [-1, 1]:
                            Z = Z_ * k
                            if not (X + Y + Z) % 2:
                                xyz = (X + Y + Z) // 2
                                x = xyz - Y
                                y = xyz - Z
                                z = xyz - X
                                if x >= 1 and y >= 1 and z >= 1:
                                    ret += 1
                                    #print(x, y,z)


        print(ret)



if __name__ == "__main__":
    run()


### FIXED CODE ###

# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#import bisect# lower_bound etc
#import numpy as np
#from copy import deepcopy
#from collections import deque
import math

def run():
    N = int(input())
    for n in range(1, N+1):
        ret = 0
        val = int(math.sqrt(2 * n))
        for X in range(2, val+1):
            for Y in range(2, val+1):
                tmp1 = 2 * n - X ** 2 - Y ** 2
                if tmp1 >= 0 and math.sqrt(tmp1) == int(math.sqrt(tmp1)):
                    Z_ = int(math.sqrt(tmp1))
                    if Z_ != 0:
                        for k in [-1, 1]:
                            Z = Z_ * k
                            if not (X + Y + Z) % 2:
                                xyz = (X + Y + Z) // 2
                                x = xyz - Y
                                y = xyz - Z
                                z = xyz - X
                                if x >= 1 and y >= 1 and z >= 1:
                                    ret += 1
                                    #print(x, y,z)


        print(ret)



if __name__ == "__main__":
    run()
### BUGGY CODE ###

from itertools import combinations_with_replacement
n = input()
sq = [map(int,raw_input().split()) for u in xrange(n)]
s_sq =[[0]*(n+1) for u in xrange(n+1)]
ma = sq[0][0]
for i in xrange(n):
    for ii in xrange(n):
        s_sq[i][ii] = sq[i][ii] + s_sq[i][ii-1] + s_sq[i-1][ii] - s_sq[i-1][ii-1]
for tx,bx in combinations_with_replacement(range(n),2):
    for ty,by in combinations_with_replacement(range(n),2):
        #print "tx,ty=",tx,ty,"bx,by=",bx,by
        ma = max([ma,s_sq[by][bx]-s_sq[ty-1][bx]-s_sq[by][tx-1]+s_sq[ty-1][tx-1]])
print ma

### FIXED CODE ###

n = input()
sq = [map(int,raw_input().split()) for u in xrange(n)]
s_sq = [[[0]*n for u in xrange(n)] for uu in xrange(n)]
#s_sq[lower_end][left_end][right_end]
ma = -1000 * 100 * 100
for y in xrange(n):
    temp = [0] * (n+1)
    for x in xrange(n):
        #make sum of the sequence left_end == 0, right_end == n
        temp[x] = temp[x-1] + sq[y][x]
    for tx in xrange(n):
        for ex in xrange(tx,n):
            s_sq[y][tx][ex] = max([0,s_sq[y-1][tx][ex]]) + temp[ex] - temp[tx-1]
            ma = max([ma,s_sq[y][tx][ex]])
print ma
### BUGGY CODE ###

#!/usr/bin/env python3
import sys
from collections import defaultdict


MOD = 1000000007  # type: int

def solve(N: int, K: int):
    comb = defaultdict(lambda: 0)
    comb[(0, 0)] = 1
    for n in range(N):
        for k in range(n+1):
            comb[(n+1, k)] = (comb[(n+1, k)] + comb[(n, k)]) % MOD
            comb[(n+1, k+1)] = (comb[(n+1, k+1)] + comb[(n, k)]) % MOD

    for n in range(1, K+1):
        blue = comb[(K-1, n-1)]
        red = comb[(N-K+1, n)]
        print(blue * red % MOD)

    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
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
from collections import defaultdict


MOD = 1000000007  # type: int

memo = dict()

def comb(n, k):
    if k < 0:
        return 0
    if n < k:
        return 0
    
    if (n, k) in memo:
        pass
    elif k == 0:
        memo[(n, k)] = 1
    elif 2 * k > n:
        memo[(n, k)] = comb(n, n-k)
    else:
        memo[(n, k)] = (comb(n, k-1) * (n - k + 1) // k)
    return memo[(n, k)]
    

def solve(N: int, K: int):
    for n in range(1, K+1):
        blue = comb(K-1, n-1)
        red = comb(N-K+1, n)
        print((blue * red) % MOD)

    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
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()
### BUGGY CODE ###

from itertools import chain
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
t=[]
for i in range(m):
    b,c=map(int,input().split())
    t.append([c]*b)
t=list(chain.from_iterable(t))
t.sort(reverse=True)

ans=0

for i in range(n):
    if i<len(t):
        ans+=max(a[i],t[i])
    else:
        ans+=a[i]
print(ans)


### FIXED CODE ###

n,m=map(int,input().split())
a=list(map(int,input().split()))
bc=[list(map(int,input().split())) for i in range(m)]
a.sort()
bc.sort(key=lambda x:x[1],reverse=True)
t=[]

for b,c in bc:
    a.extend([c]*b)
    if len(a)>2*n:
        break
a.sort(reverse=True)
print(sum(a[:n]))
### BUGGY CODE ###

n,m=map(int,input().split())
l=list(map(int,input().split()))
for i in range(m):
    l[l.index(max(l))]//=2
print(sum(l))

### FIXED CODE ###

import sys
input = sys.stdin.readline

import heapq

n,m=map(int,input().split())
a=list(map(lambda x: int(x)*-1,input().split()))
heapq.heapify(a)

for _ in range(m):
    Min=heapq.heappop(a)
    Min=(-Min//2)*-1
    heapq.heappush(a,Min)
print(sum(a)*-1)
### BUGGY CODE ###

n = int(input())
a = [int(x) for x in input().split()]

from operator import mul
from functools import reduce

ans = reduce(mul,a)
if ans <= pow(10,18):
    print(ans)
else:
    print(-1)

### FIXED CODE ###

n = int(input())
a = [int(x) for x in input().split()]
if 0 in a:
    print(0)
else:

    ans = 1
    for i in a:
        ans *= i
        if ans > pow(10,18):
            ans = -1
            break
    print(ans)
### BUGGY CODE ###

N = int(input())

# 各Kに対する約数の個数を出す

l = [0]*(N+1)

for i in range(1,N+1):
    for j in range(i, N+1, i):
        l[j] += 1
ans = 0
for i in range(1,N+1):
    ans += i * l[i]
print(ans)

### FIXED CODE ###

N = int(input())

# 各Kに対する約数の個数を出す

l = [0]*(N+1)

for i in range(1,N+1):
    for j in range(i, N+1, i):
        l[j] += 1
ans = 0
for i in range(1,N+1):
    ans += i * l[i]
print(ans)
### BUGGY CODE ###

import sys

n=int(input())
a=input().split()
for i in range(n-1):
  for j in range(i+1,n):
    if a[i]==a[j]:
      print("NO")
      sys.exit()
print("YES")

### FIXED CODE ###

import sys

n=int(input())
a=sorted([int(x) for x in input().split()])
for i in range(n-1):
  if a[i]==a[i+1]:
    print("NO")
    sys.exit()
print("YES")
### BUGGY CODE ###

import sys
input=sys.stdin.readline

def bfs(graph,N,s,t):
    S=[s]
    visited=set()
    distance={(i+1,j):0 for i in range(N) for j in range(3)}
    while len(S)>0:
        v=S.pop(0)
        if v==t:
            return True,distance[v]+1
        if v not in visited:
            visited.add(v)
            for w in graph[v]:
                distance[w] = distance[v]+1
                S.append(w)
    return False,-1
if __name__ == '__main__':
    N,M=list(map(int,input().split()))
    E=[list(map(int,input().split())) for _ in range(M)]
    S,T=list(map(int,input().split()))
    graph={(i+1,j):[] for i in range(N) for j in range(3)}
    for e in E:
        graph[(e[0],0)].append((e[1],1))
        graph[(e[0],1)].append((e[1],2))
        graph[(e[0],2)].append((e[1],0))
    flag,ans=bfs(graph,N,(S,0),(T,0))

    if flag:
        print(ans//3)
    else:
        print(-1)

### FIXED CODE ###

import sys
input=sys.stdin.readline
import heapq

def dijkstra(graph,N,s):
    distance = {(i + 1, j): 1e7 for i in range(N) for j in range(3)}
    distance[s]=0
    q=[]
    heapq.heappush(q,(distance[s],s))
    while len(q)>0:
        cost,v=heapq.heappop(q)
        if cost>distance[v]:
            continue
        else:
            for w in graph[v]:
                if distance[w]>distance[v]+1:
                    distance[w]=distance[v]+1
                    heapq.heappush(q,(distance[w],w))
    return distance


if __name__ == '__main__':
    N,M=list(map(int,input().split()))
    E=[list(map(int,input().split())) for _ in range(M)]
    S,T=list(map(int,input().split()))
    graph={(i+1,j):[] for i in range(N) for j in range(3)}
    for e in E:
        graph[(e[0],0)].append((e[1],1))
        graph[(e[0],1)].append((e[1],2))
        graph[(e[0],2)].append((e[1],0))
    distance=dijkstra(graph,N,(S,0))
    d=distance[(T,0)]
    if d%3==0:
        print(d//3)
    else:
        print(-1)
### BUGGY CODE ###

s=input()
mod=10**9+7
l=len(s)

dp=[[0 for j in range(13)] for i in range(l+1)]
dp[0][0]=1
for i in range(l):
    if s[i] == "?":
        for j in range(10):
            for k in range(13):
                dp[i+1][(k*10+j)%13] += dp[i][k]%mod
    else:
        for k in range(13):
            dp[i+1][(k*10+int(s[i]))%13]+=dp[i][k]%mod
print(dp[-1][5]%mod)

### FIXED CODE ###

s=input()
mod=10**9+7
l=len(s)

dp=[[0 for j in range(13)] for i in range(l+1)]
dp[0][0]=1
for i in range(l):
    if s[i] == "?":
        for j in range(10):
            for k in range(13):
                dp[i+1][(k*10+j)%13] += dp[i][k]%mod
    else:
        for k in range(13):
            dp[i+1][(k*10+int(s[i]))%13]+=dp[i][k]%mod
print(dp[-1][5]%mod)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import sys

N,M=map(int, sys.stdin.readline().split())
S=sys.stdin.readline().strip()

L=[]    #答えの集合
i=N
end=False
for _ in range(N):
    if end: break
    for m in range(M,0,-1):
        #print m,i+m
        if 0<=i-m and S[i-m]=="0":
            L.append(m)
            i-=m
            if i==0: end=True
            break
        
if i!=0:
    print -1
else:
    print " ".join(map(str,L[::-1]))


### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys

N,M=map(int, sys.stdin.readline().split())
S=sys.stdin.readline().strip()

L=[]    #答えの集合
for _ in range(N):
    for m in range(M,0,-1):
        if 0<=N-m and S[N-m]=="0":
            L.append(m)
            N-=m
            break
    else:
        break
        
if N!=0:
    print -1
else:
    print " ".join(map(str,L[::-1]))