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

k = int(input())
mod = 7 % k
if k % 2 == 0:
    print(-1)
else:
    ans = 1
    while mod != 0:
        mod = (10*mod + 7) % k
        ans += 1
    print(ans)

### FIXED CODE ###

k = int(input())
mod = 7 % k
if k % 2 == 0:
    print(-1)
else:
    ans = 1
    while mod != 0:
        mod = (10*mod + 7) % k
        ans += 1
        if ans >= 10**7:
            print(-1)
            break
    if ans < 10**7:
        print(ans)
### BUGGY CODE ###

n = int(input())
 
str = input()
sum = 0
two = []
three = []
for i in range(n-3):
  for j in range(i+1, n-1):
    for k in range(j+1, n):
      if str[i] == str[j]:
        break
      elif str[i] != str[k] and str[j] != str[k] and j - i != k - j:
        sum += 1
print(sum)

### FIXED CODE ###

n = int(input())
 
str = input()

r = str.count('R')
g = str.count('G')
b = str.count('B')
sum = r * g * b
for i in range(n-2):
  for j in range(i+1, n-1):
    k = 2 * j - i
    if k < n:
      if str[i] != str[j] and str[i] != str[k] and str[j] != str[k] :
        sum -= 1
    
print(sum)
### BUGGY CODE ###

def resolve():
    (N, Q) = list(map(int, input().split(" ")))
    S = input()
    LRs = [list(map(int, input().split(" "))) for i in range(Q)]
    mem = [S[i:i+2] == "AC" for i in range(len(S)-1)]

    for (l, r) in LRs:
        print(mem[l-1:r-1].count(True))

if '__main__' == __name__:
    resolve()

### FIXED CODE ###

def resolve():
    (N, Q) = list(map(int, input().split(" ")))
    S = input()
    LRs = [list(map(int, input().split(" "))) for i in range(Q)]
    mem = [0] * N
    for i in range(N-1):
        if S[i] == "A" and S[i+1] == "C":
            mem[i+1] = mem[i] + 1
        else:
            mem[i+1] = mem[i]

    for (l, r) in LRs:
        print(mem[r-1]-mem[l-1])

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

import sys, heapq, itertools
input = sys.stdin.readline
inf = float('inf')
N, M, R = map(int, input().split())
r = list(map(lambda x: int(x)-1, input().split()))

sec = [[inf] * N for _ in range(N)]
for i in range(N):
    for j in range(N):
        if i == j:
            sec[i][j] == 0
for abc in [list(map(int, input().split())) for _ in range(M)]: 
    sec[abc[0]-1][abc[1]-1] = abc[2]
    sec[abc[1]-1][abc[0]-1] = abc[2]

for k in range(N):
    for i in range(N):
        for j in range(N):
            if sec[i][j] > sec[i][k] + sec[k][j]:
                sec[i][j] = sec[i][k] + sec[k][j]

cost = inf
for perm in itertools.permutations(r):
    temp = 0
    for i in range(R-1):
        temp += sec[perm[i]][perm[i+1]]
    if temp < cost:
        cost = temp

print(cost)



### FIXED CODE ###

import sys, heapq, itertools
input = sys.stdin.readline
inf = float('inf')
N, M, R = map(int, input().split())
r = list(map(lambda x: int(x)-1, input().split()))

sec = [[inf] * N for _ in range(N)]
for i in range(N):
    for j in range(N):
        if i == j:
            sec[i][j] == 0
for abc in [list(map(int, input().split())) for _ in range(M)]: 
    sec[abc[0]-1][abc[1]-1] = abc[2]
    sec[abc[1]-1][abc[0]-1] = abc[2]
def marsh():
    for k in range(N):
        for i in range(N):
            for j in range(N):
                if sec[i][j] > sec[i][k] + sec[k][j]:
                    sec[i][j] = sec[i][k] + sec[k][j]
marsh()
cost = inf
for perm in itertools.permutations(r):
    temp = 0
    for i in range(R-1):
        temp += sec[perm[i]][perm[i+1]]
    if temp < cost:
        cost = temp

print(cost)
### BUGGY CODE ###

import copy

N,Q = map(int,input().split())
A = list(map(int,input().split()))
X = [0]*Q

for i in range(Q):
  X[i] = int(input())
  #初期値
  Takahashi = 0
  Aoki = 0
  B = copy.deepcopy(A)
  flag =0
  
  for k in range(N):
    if flag == 0: #高橋くんの行動
      Takahashi += B[-1]
      del B[-1]
      flag = 1
    
    elif flag ==1: #青木くんの行動
      j=-1
      for l in range(N-k):
        if X[i] < B[l]:
          j = l 
          break
      if j==-1:
        j = N-k-1
        
      if j == 0:
        Aoki +=B[0]
        del B[0]
        flag =0
      elif abs(X[i]-B[j]) < abs(X[i]-B[j-1]):
        Aoki += B[j]
        del B[j]
        flag =0
      else:
        Aoki += B[j-1]
        del B[j-1]
        flag = 0
  print(Takahashi)

### FIXED CODE ###

n,q = map(int,input().split())
a = list(map(int,input().split()))
query = [int(input()) for i in range(q)]

a = sorted(a)
ruiseki = [0]*(n+1)
for i in range(n):
    ruiseki[i+1] = ruiseki[i] + a[i]
    
ruiseki2 = [0]*(n+1)
if n % 2 == 1:
    for i in range(n):
        if i % 2 == 0:
            ruiseki2[i+1] = ruiseki2[i] + a[i]
        else:
            ruiseki2[i+1] = ruiseki2[i]

if n % 2 == 0:
    for i in range(n):
        if i % 2 == 1:
            ruiseki2[i+1] = ruiseki2[i] + a[i]
        else:
            ruiseki2[i+1] = ruiseki2[i]

def solve(mid, num):
    r = -((-mid) // 2)
    l = mid
    r_pos = n - r
    l_pos = n - l
    if abs(a[l_pos] - num) <= abs(a[r_pos] - num):
        return True
    else:
        return False

for i in range(q):
    num = query[i]
    ok = 1
    ng = n + 1 
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if solve(mid, num):
            ok = mid
        else:
            ng = mid
    ans = 0
    ans += ruiseki[n] - ruiseki[n-(ok+1)//2]
    nokori = n - ok
    ans += ruiseki2[nokori]
    print(ans)
### BUGGY CODE ###

import heapq

n = int(input())
p = list(map(int, input().split()))

dic = [0] * n
for i in range(n):
    dic[p[i]-1] = i+1

ans = 0
big = {0,n+1}
big.add(dic[n-1])
for i in range(n-1,0,-1):
    i_no = dic[i-1]
    bigger = big & set(range(i_no+1,n+2,1))
    smaller = big & set(range(i_no-1,-1,-1))

    if len(bigger)==1:
        r1 = n+1
        r2 = n+1
    else:
        r1, r2 = heapq.nsmallest(2, bigger)
        # r1 = min(bigger)
        # bigger.discard(r1)
        # r2 = min(bigger)

    if len(smaller)==1:
        l1 = 0
        l2 = 0
    else:
        l1, l2 = heapq.nlargest(2, smaller)
        # l1 = max(smaller)
        # smaller.discard(l1)
        # l2 = max(smaller)

    ans += i*((r2-r1)*(i_no-l1)+(r1-i_no)*(l1-l2))

    big.add(i_no)

print(ans)


### FIXED CODE ###

n = int(input())
p = list(map(int,input().split()))
p_ind = [ (p[i], i+1) for i in range(n) ]
p_ind.sort(reverse=True)

# 平方分割します。
max_n = 10**5
div_n = int(max_n**(1/2))+1
a = [[] for _ in range(div_n)]
a[0] = [0,0]
a[(n+1)//div_n].append(n+1)
a[(n+1)//div_n].append(n+1)
a_count = [0] * (div_n)
a_count[0] += 2
a_count[(n+1)//div_n] += 2

import bisect
ans = 0
for tmp in p_ind:
    val, i = tmp
    group = i//div_n
    j = bisect.bisect(a[group],i)
    #left
    if(j>1):
        left1 = a[group][j-1]
        left2 = a[group][j-2]
    elif(j==1):
        left1 = a[group][j-1]
        lg = group-1
        while(True):
            if(a_count[lg]>0):
                break
            lg -=1
        left2 = a[lg][-1]
    else:
        lg = group-1
        while(True):
            if(a_count[lg]>0):
                break
            lg -=1
        if(a_count[lg]>=2):
            left1 = a[lg][-1]
            left2 = a[lg][-2]
        else:
            left1 = a[lg][-1]
            while(True):
                lg -=1
                if(a_count[lg]>0):
                    break
            left2 = a[lg][-1]
    #right
    if(a_count[group]>=j+2):
        right1 = a[group][j]
        right2 = a[group][j+1]
    elif(a_count[group]>=j+1):
        right1 = a[group][j]
        rg = group
        while(True):
            rg += 1
            if(a_count[rg]>0):
                break
        right2 = a[rg][0]
    else:
        rg = group
        while(True):
            rg += 1
            if(a_count[rg]>0):
                break
        if(a_count[rg]>=2):
            right1 = a[rg][0]
            right2 = a[rg][1]
        else:
            right1 = a[rg][0]
            while(True):
                rg += 1
                if(a_count[rg]>0):
                    break
            right2 = a[rg][0]

    ans += ((right2 - right1)* (i - left1) + (right1 - i)* (left1 - left2)) * val
    a[group].insert(j,i)
    a_count[group] += 1

print(ans)
### BUGGY CODE ###

l, r = map(int, input().split())

def solve():
  md = 2019
  for i in range(l, r+1):
    for j in range(i+1, r+1):
      md = min((i * j) % 2019, md)
  return md

print(solve())

### FIXED CODE ###

l, r = map(int, input().split())

if r - l > 2019:
  l = 0
  r = 2018
  
def solve():
  md = 2019
  for i in range(l, r+1):
    for j in range(i+1, r+1):
      md = min((i * j) % 2019, md)
  return md

print(solve())
### BUGGY CODE ###

a=int(input())
b=list(map(int,input().split()))
c=1
for i in range(a):
  c=c*b[i]
if c>1000000000000000000:
  print(-1)
else:
  print(c)

### FIXED CODE ###

a=int(input())
b=list(map(int,input().split()))
c=1
b.sort()
if b[0]==0:
  print(0)
else:
  for i in range(a):
    c=c*b[-i]
    if c>1000000000000000000:
      break
  if c>1000000000000000000:
    print(-1)
  else:
    print(c)
### BUGGY CODE ###

N = int(input())
inputs = [int(i) for i in input().split()]

sorted_inputs = inputs[:]
sorted_inputs.sort()
left = sorted_inputs[N//2-1]
right = sorted_inputs[N//2]

for item in inputs:
    index = sorted_inputs.index(item)
    if index <= N // 2 - 1:
        print(right)
    else:
        print(left)


### FIXED CODE ###

N = int(input())
inputs = [int(i) for i in input().split()]

sorted_inputs = inputs[:]
sorted_inputs.sort()
left = sorted_inputs[N//2-1]
right = sorted_inputs[N//2]

for item in inputs:
    if item <= left:
        print(right)
    else:
        print(left)
### BUGGY CODE ###

k=int(input())
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)

ans=0
for h in range(1,k+1):
    for i in range(1,k+1):
        for j in range(1,k+1):
            ans+=gcd(h,i,j)

print(ans)

### FIXED CODE ###

k=int(input())
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)

ans=0
for h in range(1,k+1):
    for i in range(1,k+1):
        for j in range(1,k+1):
            ans+=gcd(h,i,j)

print(ans)
### BUGGY CODE ###

import re

N, Q = map(int, input().split())
S = input()
targets = [tuple(map(int, input().split())) for _ in range(Q)]

for target in targets:
    l, r = target
    s = S[l - 1:r]
    print(len(re.findall("AC", s)))


### FIXED CODE ###

N, Q = map(int, input().split())
S = input()
queries = [tuple(map(int, input().split())) for _ in range(Q)]
counters = [0 for _ in range(N + 1)]
for idx, s in enumerate(S):
    counters[idx + 1] = counters[idx] + (1 if S[idx:idx + 2] == "AC" else 0)
for q in queries:
    l, r = q
    print(counters[r - 1] - counters[l - 1])
### BUGGY CODE ###

n = int(input())
s = list(map(str,input()))
l = len(s)
box = []
for i in range(l):
  count1 = 0
  count2 = 0
  for j in range(i):
    if s[j] == "W":
      count1 += 1
  for k in range(i+1,l):
    if s[k] == "E":
      count2 += 1
  total = count1 + count2
  box.append(total)
print(min(box))

### FIXED CODE ###

n = int(input())
s = list(map(str,input()))
count = 0
for i in range(1,n):
  if s[i] == "E":
    count += 1
box = [0]*n
box[0] = count
for j in range(1,n):
  if s[j] == "E":
    count -= 1
  if s[j - 1] == "W":
    count += 1
  box[j] = count
print(min(box))
### BUGGY CODE ###

n = int(input())
s = input()

count = 0
for a in range(10):
    for b in range(10):
        for c in range(10):
            f1 = False
            f2 = False
            p1 = 0
            p2 = 0
            for i in range(0, n-2):
                if int(s[i]) == a:
                    f1 = True
                    p1 = i
                    break
            if f1:
                for j in range(p1+1, n-1):
                    if int(s[j]) == b:
                        f2 = True
                        p2 = j
                        break
            if f2:
                for k in range(p2+1, n):
                    if int(s[k]) == c:
                        count += 1
                        break
print(count)


### FIXED CODE ###

# TLE

n = int(input())
s = input()

count = 0
for a in range(10):
    for b in range(10):
        for c in range(10):
            f1 = False
            f2 = False
            p1 = 0
            p2 = 0
            for i in range(0, n-2):
                if int(s[i]) == a:
                    f1 = True
                    p1 = i
                    break
            if f1:
                for j in range(p1+1, n-1):
                    if int(s[j]) == b:
                        f2 = True
                        p2 = j
                        break
            if f2:
                for k in range(p2+1, n):
                    if int(s[k]) == c:
                        count += 1
                        break
            if not f1 or not f2:
                break
print(count)
### BUGGY CODE ###

N = int(input())
S = [input() for i in range(N)]
T = [list(s[i] for s in S) for i in range(N)]

def check(A, B):
    for i in range(N):
        si = S[A+i-N]
        ti = T[B+i-N]
        for j in range(i+1, N):
            if si[B+j-N] != ti[A+j-N]:
                return 0
    return 1

ans = 0
for i in range(N):
    ans += N*check(0, i)
print(ans)

### FIXED CODE ###

N = int(input())
S = [input() for i in range(N)]

def check(A, B):
    for i in range(N):
        for j in range(i+1, N):
            if S[(A+i)%N][(B+j)%N] != S[(A+j)%N][(B+i)%N]:
                return 0
    return 1

ans = 0
for i in range(N):
    ans += N*check(0, i)
print(ans)
### BUGGY CODE ###

def main():
    import sys
    readline = sys.stdin.readline

    INF = 10 ** 8

    H, N = map(int, readline().split())

    dp = [INF] * (H + 1)
    dp[0] = 0

    for _ in range(N):
        A, B = map(int, readline().split())
        for h in range(H):
            dp[min(H, h + A)] = min(dp[min(H, h + A)], dp[h] + B)

    print(dp[H])


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    import sys

    input = sys.stdin.readline

    inf = 10 ** 8 + 10

    h, n = map(int, input().split())
    *ab, = (list(map(int, input().split())) for _ in range(n))

    dp = [[inf] * (h + 1) for _ in range(n + 1)]
    dp[0][0] = 0
    # dp[使った魔法][与えたダメージ]=最小魔法消費

    for i, (a, b) in enumerate(ab):
        for hp in range(h + 1):
            if hp < a:
                dp[i + 1][hp] = min(dp[i][hp], dp[i + 1][0] + b)
            else:
                dp[i + 1][hp] = min(dp[i][hp], dp[i + 1][hp - a] + b)

    print(dp[n][h])


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())
### BUGGY CODE ###

import sys
import bisect
 
N, Q = map(int, input().split(' '))
G = [list(map(int, sys.stdin.readline().split(' '))) for _ in range(N)]
T = [int(sys.stdin.readline()) for _ in range(Q)]
 
G.sort(key = lambda x : -x[2])

class SegTree :
    def __init__(self, n) :
        self.n = n
        self.A = [None] * (2 << (n + 1).bit_length())
 
    def update(self, i, l, r, ll, rr, val) :
        if r <= ll or rr <= l :
            return
        if ll <= l and r <= rr :
            self.A[i] = val
            return
 
        if self.A[i] != None :
            self.A[i * 2] = self.A[i * 2 + 1] = self.A[i]
            self.A[i] = None
 
        m = (l + r) // 2
        self.update(i * 2, l, m, ll, rr, val)
        self.update(i * 2 + 1, m, r, ll, rr, val)
 
    def get(self, i, l, r, p) :
        while True :
            if self.A[i] != None or l + 1 == r :
                return self.A[i]
            m = (l+r) // 2
            if p < m :
                i = i * 2
                r = m
            else :
                i = i * 2 + 1
                l = m
 
ST = SegTree(Q)
for g in G :
    s = max(0, g[0] - g[2])
    e = g[1] - g[2]
    if e <= 0 :
        continue
 
    ll = bisect.bisect_left(T, s)
    rr = bisect.bisect_left(T, e)
 
    if ll == rr :
        continue
 
    ST.update(1, 0, Q, ll, rr, g[2])
 
for i in range(Q) :
    ans = ST.get(1, 0, Q, i)
    if ans == None :
        print(-1)
    else :
        print(ans)


### FIXED CODE ###

import sys
import bisect
 
N, Q = map(int, input().split(' '))
G = [list(map(int, sys.stdin.readline().split(' '))) for _ in range(N)]
T = [int(sys.stdin.readline()) for _ in range(Q)]

class SegTree :
    def __init__(self, n) :
        self.n = n
        self.A = [10**15] * (2 << (n + 1).bit_length())
 
    def update(self, l, r, val) :
      l += len(self.A) // 2
      r += len(self.A) // 2
      while l < r:
          if l & 1 :
              self.A[l] = min(self.A[l], val)
              l += 1
          if r & 1:
              self.A[r-1] = min(self.A[r-1], val)
              r -= 1
          l //= 2
          r //= 2

    def get(self, i) :
      i += len(self.A) // 2
      ret = self.A[i]
      while i > 0 :
          i //= 2
          ret = min(ret, self.A[i])
      return ret if ret < 10**15 else -1

ST = SegTree(Q)
for g in G :
    s = g[0] - g[2]
    e = g[1] - g[2]
 
    ll = bisect.bisect_left(T, s)
    rr = bisect.bisect_left(T, e)
 
    if ll == rr :
        continue
 
    ST.update(ll, rr, g[2])
 
for i in range(Q) :
    ans = ST.get(i)
    print(ans)
### BUGGY CODE ###

S,K=input().split()
K=int(K)
K=min(K,300)
mod=998244353
a=[]
val=0
for i in range(len(S)):
    if S[i]=="0":
        a.append(val)
        val=0
    else:
        val+=1

if val!=0:
    a.append(val)
m=len(a)

dp=[[[0 for i in range(K+1)] for j in range(K+1)] for k in range(m+1)]

for j in range(K+1):
    dp[m][j][j]=1

for i in range(m-1,-1,-1):
    for j in range(K+1):
        for k in range(K+1):
            M=max(k-j,-a[i])
            for l in range(max(0,M),K-j+1):
                dp[i][j][k]+=dp[i+1][j+l][k]
                dp[i][j][k]%=mod
            for l in range(1,min(K-k,-M)+1):
                dp[i][j][k]+=dp[i+1][j][k+l]
                dp[i][j][k]%=mod




print(dp[0][0][0])

### FIXED CODE ###

S,K=input().split()
K=int(K)
K=min(K,300)
mod=998244353
a=[]
val=0
for i in range(len(S)):
    if S[i]=="0":
        a.append(val)
        val=0
    else:
        val+=1

if val!=0:
    a.append(val)
m=len(a)
K=min(sum(a),K)

dp=[[[0 for i in range(K+1)] for j in range(K+1)] for k in range(m+1)]

for j in range(K+1):
    dp[m][j][j]=1

b=[a[i] for i in range(m)]
c=[a[i] for i in range(m)]
for i in range(1,m):
    b[i]+=b[i-1]
b=[0]+b
for i in range(m-2,-1,-1):
    c[i]+=c[i+1]
for i in range(m-1,-1,-1):
    for j in range(K+1):
        for k in range(min(b[i],K)+1):
            M=max(k-j,-a[i])
            dp[i][j][k]=sum(dp[i+1][j+l][k] for l in range(max(0,M),K-j+1))+sum(dp[i+1][j][k+l] for l in range(1,min(K-k,-M)+1))
            dp[i][j][k]%=mod

print(dp[0][0][0])
### BUGGY CODE ###

a, b , k  = map(int, input().split())
for i in range(k):
  if a > 0:
    a -= 1
  else:
    if b > 0:
      b -= 1
    else:
      break
print(a, b)
      
    

### FIXED CODE ###

a,b,k = map(int, input().split())
if a <= k:
  k = k - a
  a = 0
  b = b - k
  if b < 0:
    b = 0
  else:
    pass
else:
  a -= k
print(a, b)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(2**31-1)
input = sys.stdin.readline
write = sys.stdout.write
LMIIS = lambda : list(map(int,input().split()))
II = lambda : int(input())
dbg = lambda *something : print(*something) if DEBUG is True else 0
DEBUG = True

def main():
    N, M = LMIIS()
    dp = [0] * (M+1)

    DV = [[0] for _ in range(M+1)]

    for _ in range(N):
        A,B = LMIIS()
        if A > M:
            continue
        DV[A].append(B)

    for l in DV:
        l.sort(reverse=True)
    ans = 0

    pre = []
    for i in range(1,M+1):
        tmpL = [0] * i
        for j in range(1,i+1):

            if len(DV[j]) > i-j:
                tmpL[j-1] = DV[j][i-j]

        tmpL += pre
        tmpL.sort(reverse=True)
        ans += tmpL.pop(0)
        pre = tmpL 
    print(ans)
        
        



    pass
if __name__ == '__main__':
    main()


### FIXED CODE ###


import sys
sys.setrecursionlimit(2**31-1)
input = sys.stdin.readline
write = sys.stdout.write
LMIIS = lambda : list(map(int,input().split()))
II = lambda : int(input())
dbg = lambda *something : print(*something) if DEBUG is True else 0
DEBUG = True

def main():
    N, M = LMIIS()
    dp = [0] * (M+1)

    DV = [[0] for _ in range(M+1)]

    for _ in range(N):
        A,B = LMIIS()
        if A > M:
            continue
        DV[A].append(B)


    from heapq import heappush, heappop
    ans = 0
    h = []
    for l in DV:
        for item in l:
            heappush(h,-item)
        ans -= heappop(h)
    print(ans)
        
        



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

from fractions import gcd
from functools import reduce
k = int(input())
def GCD(*numbers):
    return reduce(gcd, numbers)
ans = 0 
for i in range(1, k+1):
  for j in range(1, k+1):
    for l in range(1, k+1):
      ans += GCD(i, j ,l)
print(ans)

### FIXED CODE ###

from math import gcd
ans = 0
k = int(input())
for i in range(1, k+1):
  for j in range(1, k+1):
    GCD = gcd(i, j)
    for l in range(1, k+1):
      ans += gcd(GCD, l)
print(ans)
### BUGGY CODE ###

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

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

print(ans  % (10**9+7) )

### FIXED CODE ###

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

S = sum(A)
ans = 0
for i in range(N-1):
  a = A[i]
  S -= a
  ans += a * S

print(ans % (10**9+7)  )
### BUGGY CODE ###

# -*- coding: utf-8 -*-

k, s = map(int, input().split())

matched = []

for x in range(0, k + 1):
    for y in range(0, k + 1):
        for z in range(0, k + 1):
            if (x + y + z) == s:
                matched.append((x, y, z))

# print(matched)
print(len(matched))

### FIXED CODE ###

# -*- coding: utf-8 -*-

k, s = map(int, input().split())

count = 0

for x in range(0, k + 1):
    for y in range(0, k + 1):
        z = s - x - y
        if 0 <= z and z <= k:
            count += 1

print(count)
### BUGGY CODE ###

N = int(input())
A = sorted(map(int, input().split()))
B = sorted(map(int, input().split()))
C = sorted(map(int, input().split()))

cnt = 0
for i in range(N):
        for j in range(N):
            if C[i] > B[j]:
                for k in range(N):
                    if B[j] > A[k]:
                        cnt+= 1
                    else:
                        break
            else:
                break
print(cnt)


### FIXED CODE ###

from  bisect import bisect_left, bisect_right

N = int(input())
A = sorted(map(int, input().split()))
B = sorted(map(int, input().split()))
C = sorted(map(int, input().split()))

cnt = 0
for b in B:
    a_cnt = bisect_left(A, b)
    c_cnt = N - bisect_right(C, b)
    cnt += a_cnt * c_cnt
print(cnt)
### BUGGY CODE ###

from bisect import bisect_left
import sys
input = sys.stdin.readline

N = int(input())
A = [int(input()) for _ in range(N)]

q = [A[0]]
for i in range(1,N):
    insert_index = bisect_left(q,A[i])
    if insert_index == 0:
        q.insert(0, A[i])
    else:
        q[insert_index-1] = A[i]

print(len(q))


### FIXED CODE ###

from bisect import bisect_left
from collections import deque
import sys
input = sys.stdin.readline

N = int(input())
A = [int(input()) for _ in range(N)]

q = deque([A[0]])
for i in range(1,N):
    insert_index = bisect_left(q,A[i])
    if insert_index == 0:
        q.appendleft(A[i])
    else:
        q[insert_index-1] = A[i]

print(len(q))
### BUGGY CODE ###

i = int(input())
a = list(map(int, input().split()))

for j in range(len(a)):
    s = a.count(j+1)
    print(s)
print(0)

### FIXED CODE ###

s = input()

j = [0]*int(s)

a = list(map(int,input().split()))
for i in  range(int(s)-1):
    j[a[i]] += 1
for i in range(len(j)-1):
    print(j[(i+1)])

print(0)