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

LI = lambda: list(map(int, input().split()))

N, K = LI()
P = LI()
C = LI()

INF = 10 ** 10


def all_minus():
    for c in C:
        if c > 0:
            return False
    return True


def main():
    if all_minus():
        ans = max(C)
        print(ans)
        return
        
    ans = -INF
    for i in range(N):
        w = [0]
        d = {i: 0}
        j = 1
        x = P[i] - 1
        while x not in d:
            d[x] = j
            w.append(w[j - 1] + C[x])
            x = P[x] - 1
            j += 1

        a, b = d[x], j
        for _ in range(b - a):
            w.append(w[-1] + C[x])
            x = P[x] - 1

        if K < 2 * b - a or w[b] - w[a] <= 0:
            v = max(w[:K + 1])
            ans = max(ans, v)
            continue
        
        v = w[a]
        k = K - a
        r = k // (b - a) - 1
        k -= r * (b - a)
        v += r * (w[b] - w[a])
        v += max(w[a : a + k + 1]) - w[a]
        ans = max(ans, v)
    print(ans)
        
                
if __name__ == "__main__":
    main()


### FIXED CODE ###

LI = lambda: list(map(int, input().split()))

N, K = LI()
P = LI()
C = LI()

INF = 10 ** 10


def all_minus():
    for c in C:
        if c > 0:
            return False
    return True


def main():
    if all_minus():
        ans = max(C)
        print(ans)
        return
        
    ans = -INF
    for i in range(N):
        w = [0]
        d = {i: 0}
        j = 1
        x = P[i] - 1
        while x not in d:
            d[x] = j
            w.append(w[j - 1] + C[x])
            x = P[x] - 1
            j += 1

        a, b = d[x], j
        for _ in range(b - a):
            w.append(w[-1] + C[x])
            x = P[x] - 1

        if K < 2 * b - a or w[b] - w[a] <= 0:
            v = max(w[:K + 1])
            ans = max(ans, v)
            continue
        
        v = w[a]
        k = K - a
        r = k // (b - a) - 1
        k -= r * (b - a)
        v += r * (w[b] - w[a])
        v += max(w[a : a + k + 1]) - w[a]
        ans = max(ans, v)
    print(ans)
        
                
if __name__ == "__main__":
    main()
### BUGGY CODE ###

H, W, D = map(int, input().split())
A = tuple(tuple(map(int, input().split())) for _ in range(H))

pos = [0] * (H * W + 1)

for i in range(H):
    for j in range(W):
        pos[A[i][j]] = (i, j)

def L1(p1, p2):
    return abs(p1[0] - p2[0]) + abs(p1[1] - p2[1])

costs = [-1] * (H * W + 1)

def solve(l, r):
    total = 0
    for i in range(l, r, D):
        if costs[i] == -1:
            costs[i] = L1(pos[i], pos[i + D])
        total += costs[i]
    return total

Q = int(input())
for _ in range(Q):
    print(solve(*map(int, input().split())))


### FIXED CODE ###

H, W, D = map(int, input().split())
A = tuple(tuple(map(int, input().split())) for _ in range(H))

pos = [0] * (H * W + 1)

for i in range(H):
    for j in range(W):
        pos[A[i][j]] = (i, j)

def L1(p1, p2):
    return abs(p1[0] - p2[0]) + abs(p1[1] - p2[1])

costs = []

for i in range(H * W + 1):
    costs.append(0 if i <= D else costs[i - D] + L1(pos[i - D], pos[i]))

Q = int(input())
for _ in range(Q):
    L, R = map(int, input().split())
    print(costs[R] - costs[L])
### BUGGY CODE ###

import collections

N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
A_dict=collections.Counter(A)
B_dict=collections.Counter(B)
C_dict=collections.Counter(C)

A_sorted=sorted(A_dict)
B_sorted=sorted(B_dict)
C_sorted=sorted(C_dict)

C_sum=len(C)
C_num=[]

for i in B_sorted:
    C_sum=len(C)
    for j in C_sorted:
        if j<=i:
            C_sum-=C_dict[j]

    C_num.append(C_sum)

ans=0

for i in A_sorted:
    c=0
    for j in B_sorted:
        if i<j:
            ans += A_dict[i] * B_dict[j] * C_num[c]
        c+=1

print(ans)


### FIXED CODE ###

from bisect import bisect_left
from bisect import bisect_right

N=int(input())

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

A.sort()
B.sort()
C.sort()

ans=0
for i in range(N):
    idxa=bisect_left(A,B[i])
    idxc=bisect_right(C,B[i])
    ans+=idxa*(N-idxc)

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

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

Q = int(input())
BC= [input().split() for _ in range(Q)]

for j in range(Q):
    A = [int(BC[j][1]) if i == int(BC[j][0]) else i for i in A]
    print(sum(A))

### FIXED CODE ###

from collections import Counter
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
ans = sum(A)
C = Counter(A)

for i in range(Q):
    b, c = map(int, input().split())
    if C[b] != 0:
        cnt = C[b]
        C[c] += cnt
        C[b] = 0
        ans += (c-b) * cnt
    print(ans)
### BUGGY CODE ###

K,S=map(int,input().split())
if 2<=K<=2500 and 0<=S<=3*K:
    count=0
    Ks=[]
    wa=[]
    for i in range(K+1):
        Ks.append(i)
    X,Y,Z =Ks,Ks,Ks
    for x in X:
        X_=[]
        X_.append(x)
        for y in Y:
            X_Y_=[]
            X_Y_=X_.copy()
            X_Y_.append(y)
            for z in Z:
                X_Y_Z_=X_Y_.copy()
                X_Y_Z_.append(z) 
                wa_=sum(X_Y_Z_)
                wa.append(wa_)
    print(len([c for c in wa if c==S]))

### FIXED CODE ###

import sys
input = sys.stdin.readline
 
K,S=map(int,input().split())
count=0
for x in range(K+1):
    for y in range(K+1):
        if S-(x+y)>=0 and S-(x+y)<=K: count+=1
print(count)
### BUGGY CODE ###

n=int(input())
s=input()
ans=float("inf")
for i in range(n+1):
  a=s[:i].count("#")+s[i:].count(".")
  ans=min(ans,a)
print(ans)

### FIXED CODE ###

n=int(input())
s=input()
a=s.count(".")
ans=a
for i in range(n):
  if s[i]==".":
    a-=1
  else:
    a+=1
  ans=min(ans,a)
print(ans)
### BUGGY CODE ###

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

        l = []

        for i in range(N-1):
                if i+1 in A:
                        l.append(A.count(i+1))
                else:
                        l.append(0)
        l.append(0)


        ans = "\n".join([str(x) for x in l])
        print(ans)

if __name__=="__main__":
        main()

### FIXED CODE ###

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

        l = [0]*N

        for a in A:
                l[a-1] += 1

        ans = "\n".join([str(x) for x in l])
        print(ans)

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

N, Q = map(int, input().split())
S = input()
SC = [0] * (N - 1)
for i in range(N - 1):
    if S[i:i + 2] == "AC":
        SC[i] = 1

for i in range(Q):
    l, r = map(int, input().split())
    print(sum(SC[l - 1:r - 1]))


### FIXED CODE ###

N, Q = map(int, input().split())
S = input()
SC = [0] * N

for i in range(N - 1):
    if S[i:i + 2] == "AC":
        SC[i + 1] = SC[i] + 1
    else:
        SC[i + 1] = SC[i]

for i in range(Q):
    l, r = map(int, input().split())
    print(SC[r - 1] - SC[l - 1])
### BUGGY CODE ###

from collections import deque

H,W = map(int, input().split())
maze = [input() for _ in range(H)]
visited = [[False]*W for _ in range(H)]
q = deque([])

# initialize
for h in range(H):
    for w in range(W):
        if maze[h][w] == "#":
            q.append((h,w,0))
            visited[h][w] = True

ans = 0
while q:
    h,w,d = q.popleft()
    for dy,dx in zip([0,0,-1,1], [-1,1,0,0]):
        nh, nw = h+dy, w+dx
        if not(0<=nh<H and 0<=nw<W):
            continue
        if not visited[nh][nw]:
            q.append((nh,nw,d+1))
            visited[nh][nw] = True
            ans = max(ans, d+1)

print(ans)


### FIXED CODE ###

from collections import deque

H,W = map(int, input().split())
maze = [input() for _ in range(H)]
visited = [[False]*W for _ in range(H)]
q = deque([])

# initialize
for h in range(H):
    for w in range(W):
        if maze[h][w] == "#":
            q.append((h,w,0))
            visited[h][w] = True

ans = 0
while q:
    h,w,d = q.popleft()
    for dy,dx in zip([0,0,-1,1], [-1,1,0,0]):
        nh, nw = h+dy, w+dx
        if not(0<=nh<H and 0<=nw<W):
            continue
        if not visited[nh][nw]:
            q.append((nh,nw,d+1))
            visited[nh][nw] = True
            ans = max(ans, d+1)

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

import collections

n = int(input())
a = list(map(int, input().split()))
c_lst = []
c = collections.Counter(a)
for i in c.most_common()[::-1]:
    if i[1] >= 2:
        c_lst.append(list(i))
if c_lst:
    values, counts = zip(*c_lst)
else:
    values = []

cnt = []
for i in range(len(c_lst)):
    cnt.append((c_lst[i][1] * (c_lst[i][1] - 1)) // 2)
cnt_ = sum(cnt)
    
for i in a:
    ans = 0
    if i in values:
        ans += ((c_lst[values.index(i)][1] - 1) * (c_lst[values.index(i)][1] - 2)) // 2
        ans += cnt_ - cnt[values.index(i)]
    else:
        ans = cnt_
    print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
cnt = [0] * n
for i in a:
    cnt[i-1] += 1
total = [0] * n
for i in range(n):
    total[i] = cnt[i] * (cnt[i] - 1) // 2
total_sum = sum(total)
for i in a:
    ans = total_sum
    ans -= total[i-1]
    ans += (cnt[i-1] - 1) * (cnt[i-1] - 2) // 2
    print(ans)
### BUGGY CODE ###

def main():
    N,K=map(int,input().split())
    keta=1
    flag=0
    A=K
    while flag==0:
        if A<=N and A*K>N:
            print(keta+1)
            return
        A*=K
        keta= keta+1
main()

### FIXED CODE ###

def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out
    
def main():
    N,K=map(int,input().split())
    print(len(Base_10_to_n(N,K)))
main()
### BUGGY CODE ###

while 1:
    m=int(raw_input())
    if m==0:break
    st=[map(int,raw_input().split()) for _ in xrange(m)]
    n=int(raw_input())
    pi=[map(int,raw_input().split()) for _ in xrange(n)]
    d=[[st[i][0]-st[0][0],st[i][1]-st[0][1]] for i in xrange(1,m)]
    for i in xrange(n):
        mo=[[pi[j][0]-pi[i][0],pi[j][1]-pi[i][1]] for j in xrange(n)]
        cnt=0
        for k in xrange(m-1):
            if not d[k] in mo:continue
            else:cnt+=1
        if cnt==m-1:
            print pi[i][0]-st[0][0],pi[i][1]-st[0][1]
            break

### FIXED CODE ###

while 1:
    m=int(raw_input())
    if m==0:break
    st=[map(int,raw_input().split()) for _ in xrange(m)]
    n=int(raw_input())
    pi=[map(int,raw_input().split()) for _ in xrange(n)]
    d=[[st[i][0]-st[0][0],st[i][1]-st[0][1]] for i in xrange(1,m)]
    for i in xrange(n):
        mo=[[pi[j][0]-pi[i][0],pi[j][1]-pi[i][1]] for j in xrange(n)]
        cnt=0
        cnt1=0
        for k in xrange(m-1):
            if not d[k] in mo:break
            else:cnt+=1
        if cnt==m-1:
            print pi[i][0]-st[0][0],pi[i][1]-st[0][1]
            break
### BUGGY CODE ###

n = int(input())
s = input()
r = []
g = []
b = []
res = 0
for i in range(n):
  if s[i] == 'R':
    r.append(i)
  elif s[i] == 'G':
    g.append(i)
  else:
    b.append(i)
for i in b:
  for j in r:
    res += len(g) - int((i + j) / 2 in g) - int(2 * i - j in g) - int(2 * j - i in g)
print(res)


### FIXED CODE ###

n=int(input())
s=input()
R=[]
G={}
B=[]
for i in range(n):
  if s[i]=='R':
    R.append(i+1)
  elif s[i]=='G':
    G[i+1]=G.get(i+1,0)+1
  else:
    B.append(i+1)
res=len(R)*len(G)*len(B)
for i in R:
  for j in B:
    if ((i+j)%2==0 and G.get((i+j)//2,0)==1):
      res-=1
    if G.get(2*max(i,j)-min(i,j),0)==1:
      res-=1
    if G.get(2*min(i,j)-max(i,j),0)==1:
      res-=1
print(res)
### BUGGY CODE ###

n, k = map(int,input().split())
s = []
mod = 998244353
for i in range(k):
  l, r = map(int,input().split())
  for j in range(l,r+1):
    s.append(j)
s.sort()
cnt = [0]*n
cnt[0] = 1
for i in range(n):
  for d in range(len(s)):
    if i+s[d] <= n-1:
      cnt[i+s[d]] += cnt[i]
    elif i+s[d] > n-1:
      break
print(cnt[-1] % mod)

### FIXED CODE ###

#dpで素直にやるとO(N^2)だから、累積和で高速化しO(KN)にする

n, k = map(int,input().split())
mod = 998244353

s = []
for i in range(k):
  s.append(list(map(int,input().split())))

cnt = [0]*n
cnt[0] = 1
sum = [0]*n
sum[0] = 1
for i in range(1,n):
  for j in range(k):
    if i > s[j][1]:
      cnt[i] += sum[i-s[j][0]] - sum[i-s[j][1]-1]
    elif i >= s[j][0]:
      cnt[i] += sum[i-s[j][0]]
    cnt[i] %= mod
    sum[i] = (sum[i-1] + cnt[i]) % mod

print(cnt[-1])
### BUGGY CODE ###

import sys
input = sys.stdin.readline

n = int(input())
ss = [input() for _ in range(n)]

sorted_ss = [''.join(sorted(s)) for s in ss]
sorted_set = set(sorted_ss)

cnt = 0
for s in sorted_set:
	c = sorted_ss.count(s)
	cnt += c * (c - 1) // 2

print(cnt)

### FIXED CODE ###

from collections import Counter

n = int(input())
ss = [input() for _ in range(n)]

sorted_ss = [''.join(sorted(s)) for s in ss]
sorted_counter = Counter(sorted_ss)

cnt = sum([n * (n - 1) // 2 for n in sorted_counter.values()])
print(cnt)
### BUGGY CODE ###

import sys
from heapq import heappush, heappop
sys.setrecursionlimit(10**6)

def input():
    return sys.stdin.readline()[:-1]

n, m = [int(item) for item in input().split()]
a = [int(item) for item in input().split()]
k = 0

pqs = []
edge = [[] for _ in range(n)]
for i in range(m):
    x, y = [int(item) for item in input().split()]
    edge[x].append(y)
    edge[y].append(x)

def dfs(n):
    kind[n] = k
    heappush(pqs[k], a[n])
    for item in edge[n]:
        if kind[item] == -1:
            dfs(item)

kind = [-1] * n
for i, item in enumerate(kind):
    if item == -1:
        pqs.append([])
        dfs(i)
        k += 1

if k == 1:
    print(0)
    exit()
    
ans = 0
for i in range(k):
    val = heappop(pqs[i])
    ans += val
pqs = sum(pqs, [])
pqs.sort()
for i in range(k-2):
    if i > len(pqs) - 1:
        print("Impossible")
        exit()
    ans += pqs[i]
print(ans)

### FIXED CODE ###

import sys
from heapq import heappush, heappop
sys.setrecursionlimit(10**6)

def input():
    return sys.stdin.readline()[:-1]

n, m = [int(item) for item in input().split()]
a = [int(item) for item in input().split()]
k = 0

pqs = []
edge = [[] for _ in range(n)]
for i in range(m):
    x, y = [int(item) for item in input().split()]
    edge[x].append(y)
    edge[y].append(x)

def dfs(n):
    kind[n] = k
    heappush(pqs[k], a[n])
    for item in edge[n]:
        if kind[item] == -1:
            dfs(item)

kind = [-1] * n
for i, item in enumerate(kind):
    if item == -1:
        pqs.append([])
        dfs(i)
        k += 1

if k == 1:
    print(0)
    exit()
    
ans = 0
for i in range(k):
    val = heappop(pqs[i])
    ans += val
pqs = [flatten for inner in pqs for flatten in inner] 
pqs.sort()
for i in range(k-2):
    if i > len(pqs) - 1:
        print("Impossible")
        exit()
    ans += pqs[i]
print(ans)
### BUGGY CODE ###

from sys import setrecursionlimit


def f(u, l, r, a, dp):
    if l > r:
        return (0, 0)
    if dp[l][r] is not None:
        return dp[l][r]
    x, y = f(u ^ 1, l + 1, r, a, dp)
    if u == 0:
        t0 = (x + a[l], y)
    else:
        t0 = (x, y + a[l])
    x, y = f(u ^ 1, l, r - 1, a, dp)
    if u == 0:
        t1 = (x + a[r], y)
    else:
        t1 = (x, y + a[r])
    if t0[u] - t0[u ^ 1] > t1[u] - t1[u ^ 1]:
        result = t0
    else:
        result = t1
    dp[l][r] = result
    return result


setrecursionlimit(1000000)

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

dp = [[None] * N for _ in range(N)]
t = f(0, 0, N - 1, a, dp)
print(t[0] - t[1])


### FIXED CODE ###

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

dp = [[0] * (N + 1) for _ in range(N + 1)]
for l in range(1, N + 1):
  for i in range(N + 1 - l):
    j = i + l
    if (N - l) % 2 == 0:
      dp[i][j] = max(dp[i + 1][j] + a[i], dp[i][j - 1] + a[j - 1])
    else:
      dp[i][j] = min(dp[i + 1][j] - a[i], dp[i][j - 1] - a[j - 1])
print(dp[0][N])
### BUGGY CODE ###

import math
import random
import decimal

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

def quick(x):
  pri = math.floor(A * x / B)
  lat = A * math.floor(x / B)
  return math.floor(pri - lat)

decimal.getcontext().prec = 6
max = quick(decimal.Decimal(N))
for i in range(800000):
  ran = math.floor(random.uniform(0, N))
  tem = quick(decimal.Decimal(ran))
  if(max < tem):
    max = tem

print(max)


### FIXED CODE ###

import math
import random

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

def quick(x):
  pri = (A * x // B)
  lat = A * (x // B)
  return math.floor(pri - lat)

max = quick(N)
for i in range(8000000):
  ran = math.floor(random.uniform(0, N))
  tem = quick(ran)
  if(max < tem):
    max = tem

print(max)
### BUGGY CODE ###

def exteuc(a, b):
    # ax + by = gcd(a, b)
    if b == 0:
        return 1, 0, a
    y, x, v = exteuc(b, a % b)
    y -= (a//b) * x
    return x, y, v


def modinv(a, mod):
    x, _, _ = exteuc(a, mod)
    return x % mod


def comb(n, k, mod, precalc_modinvs):
    if k > n//2:
        return comb(n, n - k, mod, precalc_modinvs)
    ret = 1
    for i in range(k):
        ret *= n - i
        ret *= precalc_modinvs[k - i]
        ret %= mod
    return ret


def main():
    MOD = 10**9 + 7
    N = int(input())
    A = list(map(int, input().split(' ')))
    # calculate mod inverse
    precalc_modinvs = [modinv(i, MOD) for i in range(N + 2)]
    # calculate duplicate indices
    # Ex. [1, 4, 2, 1, 3] -> 0, 3
    dup_first_index, dup_second_index = -1, -1
    indices = [-1 for _ in range(N)]
    for i, a in enumerate(A):
        if indices[a - 1] != -1:
            dup_first_index, dup_second_index = indices[a - 1], i
            break
        indices[a - 1] = i
    # calculate answer
    ans = [0 for _ in range(N + 1)]
    for i in range(N + 1):
        ans[i] = comb(N + 1, i + 1, MOD, precalc_modinvs)
        # Ex. [1, 4, 2, 5, 4, 3, 6] -> [1] + [3, 6] -> 3
        s = dup_first_index + N - dup_second_index
        if s >= i:
            ans[i] -= comb(s, i, MOD, precalc_modinvs)
    for a in ans:
        print(a)


if __name__ == '__main__':
    main()

### FIXED CODE ###

def exteuc(a, b):
    # ax + by = gcd(a, b)
    if b == 0:
        return 1, 0, a
    y, x, v = exteuc(b, a % b)
    y -= (a//b) * x
    return x, y, v


def modinv(a, mod):
    x, _, _ = exteuc(a, mod)
    return x % mod


def main():
    MOD = 10**9 + 7
    N = int(input())
    A = list(map(int, input().split(' ')))
    # calculate duplicate indices
    # Ex. [1, 4, 2, 1, 3] -> 0, 3
    dup_first_index, dup_second_index = -1, -1
    indices = [-1 for _ in range(N)]
    for i, a in enumerate(A):
        if indices[a - 1] != -1:
            dup_first_index, dup_second_index = indices[a - 1], i
            break
        indices[a - 1] = i
    # Ex. [1, 4, 2, 5, 4, 3, 6] -> [1] + [3, 6] -> 3
    s = dup_first_index + N - dup_second_index
    # calculate answer
    ans = [0 for _ in range(N + 1)]
    comb_n1, comb_s = N + 1, 1  # comb(N + 1, 1), comb(s, 0)
    for i in range(N + 1):
        ans[i] = comb_n1  # comb(N + 1, i + 1)
        comb_n1 *= (N + 1) - (i + 1)
        comb_n1 *= modinv(i + 2, MOD)
        comb_n1 %= MOD
        if s >= i:
            ans[i] -= comb_s  # comb(s, i)
            comb_s *= s - i
            comb_s *= modinv(i + 1, MOD)
            comb_s %= MOD
        ans[i] %= MOD
    for a in ans:
        print(a)


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



def read_input():
    n = int(input())
    alist = list(map(int, input().split()))

    return n, alist


def possibility_check(n, alist):
    occurs = {}
    for a in alist:
        if a in occurs.keys():
            occurs[a] += 1
        else:
            occurs[a] = 1

    if n % 2:
        if occurs[0] == 1:
            for i in range(2, n, 2):
                if occurs[i] != 2:
                    return False
            return True
        else:
            return False
    else:
        for i in range(1, n, 2):
            if occurs[i] != 2:
                return False
        return True

def submit():
    n, alist = read_input()

    if possibility_check(n, alist):
        ans = (2 ** (n // 2)) % (10**9 + 7)
        print(ans)
    else:
        print(0)


if __name__ == '__main__':
    submit()


### FIXED CODE ###



def read_input():
    n = int(input())
    alist = list(map(int, input().split()))

    return n, alist


def possibility_check(n, alist):
    alist.sort()

    if n % 2:
        even = [x for x in range(2, n) if x % 2 == 0]
        comp = [0] + even + even
        comp.sort()

    else:
        odd = [x for x in range(1, n) if x % 2 == 1]
        comp = odd + odd
        comp.sort()

    if alist == comp:
        return True
    else:
        return False


def submit():
    n, alist = read_input()

    if possibility_check(n, alist):
        # ans = (2 ** (n // 2)) % (10**9 + 7)
        ans = 1
        for i in range(n // 2):
            ans *= 2
            if ans > 10**9 + 7:
                ans %= (10**9 + 7)
        print(ans)
    else:
        print(0)


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

H, W, K = map(int, input().split())

area = [input() for _ in range(H)]
ans = float('inf')
for i in range(1 << H-1):
    flag = False
    tmp_ans = 0
    mapping = [-1 for n in range(H)]
    tmp = 0
    for j in range(H):
        if i >> j & 1 == 1:
            tmp_ans += 1
            mapping[j] = tmp
            tmp += 1
        else:
            mapping[j] = tmp
    T = tmp_ans+1
    counter = [0 for _ in range(T)]

    for w in range(W):
        tmp_counter = [0 for _ in range(T)]
        for h in range(H):
            if area[h][w] == '1':
                tmp_counter[mapping[h]] += 1
        for tmp in tmp_counter:
            if tmp > K:
                flag = True
        if flag:
            tmp_ans = float('inf')
            break

        for k, tmp in enumerate(tmp_counter):
            if counter[k]+tmp > K:
                tmp_ans += 1
                counter = tmp_counter
                break
            else:
                counter[k] += tmp
    ans = min(ans, tmp_ans)

print(ans)


### FIXED CODE ###

H, W, K = map(int, input().split())

area = [input() for _ in range(H)]
ans = float('inf')
S = []
for w in range(W):
    s = [0, ]
    for h in range(H):
        if area[h][w] == '1':
            s.append(s[-1]+1)
        else:
            s.append(s[-1])
    S.append(s)

for i in range(1 << H-1):
    flag = False
    tmp_ans = 0

    tmp = 0
    flag1 = [False for _ in range(H)]
    flag1[-1] = True
    for j in range(H):
        if i >> j & 1 == 1:
            tmp_ans += 1
            flag1[j] = True
    T = tmp_ans+1
    counter = [0 for _ in range(T)]

    for w in range(W):
        tmp_counter = []
        before = 0
        for k, f in enumerate(flag1):
            if f:
                tmp_counter.append(S[w][k+1] - S[w][before])
                before = k+1
        
        for tmp in tmp_counter:
            if tmp > K:
                flag = True
        if flag:
            tmp_ans = float('inf')
            break

        for k, tmp in enumerate(tmp_counter):
            if counter[k]+tmp > K:
                tmp_ans += 1
                counter = tmp_counter
                break
            else:
                counter[k] += tmp
    ans = min(ans, tmp_ans)

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

n = int(input())

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

ans = [a.count(i+1) for i in range(n)]

for i in ans:
  print(i)

### FIXED CODE ###

n = int(input())

a = [0 for _ in range(n)]
for i in input().split():
  a[int(i)-1] += 1


for i in a:
  print(i)