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

def main():
  from fractions import Fraction
  from collections import defaultdict
  N = int(input())

  MOD = 10**9 + 7

  zero_zero_count = 0
  zero_one_count = 0
  one_zero_count = 0
  dd_ba = defaultdict(int, {})
  for _ in range(N):
    a,b = map(int,input().split())
    if (a==0)and(b==0):
      zero_zero_count += 1
    elif (a==0):
      zero_one_count += 1
    elif (b==0):
      one_zero_count += 1
    else:
      dd_ba[Fraction(-b, a)] += 1

  ans = (2**zero_one_count + 2**one_zero_count -1)
  flag_dd = defaultdict(bool, {})

  iterator = list(dd_ba.items())
  for key,value in iterator:
    if flag_dd[key]:
      continue
    x = Fraction(key.denominator, -(key.numerator))
    y = dd_ba[x]
    ans *= (2**y + 2**value - 1) % MOD
    ans %= MOD
    flag_dd[x] = True

  ans += zero_zero_count - 1
  print(ans%MOD) 

if __name__=='__main__':
  main()

### FIXED CODE ###

def main():
  from math import gcd
  from collections import defaultdict
  import sys
  input = sys.stdin.readline
  N = int(input())
  AB = [list(map(int,input().split())) for _ in range(N)]

  MOD = 10**9 + 7

  zero_zero_count = 0
  zero_one_count = 0
  one_zero_count = 0
  dd_ba = defaultdict(int, {})
  for a,b in AB:
    if (a==0)and(b==0):
      zero_zero_count += 1
    elif (a==0):
      zero_one_count += 1
    elif (b==0):
      one_zero_count += 1
    else:
      if a * b < 0:
        a = abs(a)
        b = abs(b)
        g = gcd(a, b)
        dd_ba[(b//g, a//g)] += 1
      else:
        a = abs(a)
        b = abs(b)
        g = gcd(a, b)
        dd_ba[(-b//g, a//g)] += 1

  ans = (2**zero_one_count + 2**one_zero_count -1)
  dd_flag = defaultdict(bool, {})

  for key,value in tuple(dd_ba.items()):
    if dd_flag[key]:
      continue
    
    key_0 = key[0]
    key_1 = key[1]
    if key_0<0:
      x = (key_1, -key_0)
    else:
      x = (-key_1, key_0)
    y = dd_ba[x]
    ans *= (2**y + 2**value - 1) % MOD
    ans %= MOD
    dd_flag[x] = True

  ans += zero_zero_count - 1
  print(ans%MOD) 

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

S = input()
Q = int(input())
for i in range(Q):
    Queryi = list(map(str, input().split()))
    if Queryi[0] == '1':
        S = S[::-1]
    else: #i[0] == '2'
        if Queryi[1] == '1':
            S = Queryi[2] + S
        else: #i[1] == '2'
            S = S + Queryi[2]
print(S)

### FIXED CODE ###

from collections import deque

S = input()
Q = int(input())
d = deque(list(S))
tf = 1

for i in range(Q):
    Queryi = list(map(str, input().split()))
    if Queryi[0] == '1':
        tf *= -1
    else:   #Queryi[0] == '2'
        if tf == 1:
            if Queryi[1] == '1':
                d.appendleft(Queryi[2])
            else: #Queryi[1] == '0'
                d.append(Queryi[2])
        else: #tf = -1
            if Queryi[1] == '1':
                d.append(Queryi[2])
            else: #Queryi[1] == '1'
                d.appendleft(Queryi[2])

if tf == -1:
    d.reverse()

print(''.join(d))
### BUGGY CODE ###

import sys
sys.setrecursionlimit(1<<20)
h,w=[int(x) for x in input().split()]
ch,cw=[int(x) for x in input().split()]
dh,dw=[int(x) for x in input().split()]
ch-=1
cw-=1
dh-=1
dw-=1

s=[]
for _ in range(h):
    s.append(list(input()))

nxt=[[ch,cw,0]]
#再起
def rcl(y,x,now):
    
    if y==dh and x==dw:
        print(now)
        exit()
        
    s[y][x]='#'
    #5*5
    for i in range(-2,3):
        for j in range(-2,3):
            if i==0 and j==0:
                continue
            if y+i<0 or h<=y+i:
                continue
            if x+j<0 or w<=x+j:
                continue
            if s[y+i][x+j]!='#':
                nxt.append([y+i,x+j,now+1])
    # 四方を見る
    for i in range(4):
        yy,xx=-1,0
        if i==1:yy,xx=0,1
        if i==2:yy,xx=1,0
        if i==3:yy,xx=0,-1
        
        if y+yy<0 or h<=y+yy or x+xx<0 or w<=x+xx:
            continue
        if s[y+yy][x+xx]=='#':
            continue
        rcl(y+yy,x+xx,now)


while nxt:
    i=nxt.pop(0)
    if i[0]==dh and i[1]==dw:
        print(i[2])
        exit()
    rcl(i[0],i[1],i[2])
print(-1)

### FIXED CODE ###

import sys
sys.setrecursionlimit(1<<20)
h,w=[int(x) for x in input().split()]
ch,cw=[int(x) for x in input().split()]
dh,dw=[int(x) for x in input().split()]
ch-=1
cw-=1
dh-=1
dw-=1

s=[]
for _ in range(h):
    s.append(list(input()))

nxt=[[ch,cw,0]]
#再起
def rcl(y,x,now):
    
    if y==dh and x==dw:
        print(now)
        exit()
    
    if s[y][x]=='#':
        return
    
    s[y][x]='#'
    # 四方を見る
    for i in range(4):
        yy,xx=-1,0
        if i==1:yy,xx=0,1
        if i==2:yy,xx=1,0
        if i==3:yy,xx=0,-1
        
        if y+yy<0 or h<=y+yy or x+xx<0 or w<=x+xx:
            continue
        if s[y+yy][x+xx]=='#':
            continue
        
        rcl(y+yy,x+xx,now)
    #5*5
    for i in range(-2,3):
        for j in range(-2,3):
            if i==0 and j==0:
                continue
            if y+i<0 or h<=y+i or x+j<0 or w<=x+j:
                continue
            if s[y+i][x+j]=='.':
                nxt.append([y+i,x+j,now+1])
                s[y+i][x+j]=now+1


while nxt:
    i=nxt.pop(0)
    if i[0]==dh and i[1]==dw:
        print(i[2])
        exit()
    rcl(i[0],i[1],i[2])
print(-1)
### BUGGY CODE ###

import sys
n=int(input())
a=list(map(int,input().split()))
s=a[0]
for i in range(1,n):
    s*=a[i]
if s>10**18:
    print(-1)
    sys.exit()
print(s)

### FIXED CODE ###

import sys
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
s=a[n-1]
if s==0:
    print(0)
else:
    for i in range(0,n-1):
        s*=a[i]
        if s>10**18:
            print(-1)
            sys.exit()
    print(s)
### BUGGY CODE ###

from collections import Counter
n = int(input())
res = list(map(int,input().split()))
res2 = [0] * len(res)
a = Counter(res)

for i in a.keys():
    a[i] -= 1
    sums = 0
    for j in a.values():
        sums += j * (j - 1) // 2
    a[i] += 1
    for x in range(len(res)):
        if res[x] == i:
            res2[x] = sums
        else:
            res2[x] = res2[x]
for k in res2:
    print(k)

### FIXED CODE ###

from collections import Counter
n = int(input())
res = list(map(int,input().split()))
a = Counter(res)

sums = 0

for i in a.values():
    sums +=  i * (i - 1) // 2

for j in res:
    print(sums - a[j] * (a[j] -1) //2 + (a[j]-1) * (a[j] -2 ) // 2)
### BUGGY CODE ###

import functools
import operator

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

prod = functools.partial(functools.reduce, operator.mul)
for c, i in enumerate(range(K, N+1)):
    sum_prod = prod(A[i-K:i])
    if i > K:
        if sum_prod > tmp_sum_prod:
            print('Yes')
        else:
            print('No')
    tmp_sum_prod = sum_prod


### FIXED CODE ###

import functools
import operator

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

# prod = functools.partial(functools.reduce, operator.mul)
# tmp_sum_prod = prod(A[:K])
for i in range(K, N):
    sum_prod = (A[i]/A[i-K])
    if sum_prod > 1.0:
        print('Yes')
    else:
        print('No')
    tmp_sum_prod = sum_prod
### BUGGY CODE ###

import sys
from collections import deque
from collections import defaultdict
import math
sys.setrecursionlimit(20000000)
h,w = map(int,input().split())
s = []
for i in range(h):
        a = [i for i in input().rstrip()]
        s.append(a)
x = [[[0,0,0,0]for i in range(w)] for j in range(h)]
for i in range(h):
        for j in range(w):
                if s[i][j] == "." and 0<j and s[i][j-1] == ".":
                        x[i][j][0] = x[i][j-1][0] +1

for i in range(h):
        for j in range(w-1,-1,-1):
                if s[i][j] == "." and w-1>j and s[i][j+1] == ".":
                        x[i][j][1] = x[i][j+1][1] +1

for i in range(w):
        for j in range(h-1,-1,-1):
                if s[j][i] == "." and h-1>j and s[j+1][i] == ".":
                        x[j][i][2] = x[j+1][i][2] +1

for i in range(w):
        for j in range(h):
                if s[j][i] == "." and 0<j and s[j-1][i] == ".":
                        x[j][i][3] = x[j-1][i][3] +1                   
ans = 0
for i in range(h):
        for j in range(w):
                if s[i][j] == ".":
                        ans = max(ans,sum(x[i][j])+1)

print(ans)

### FIXED CODE ###

import sys
from collections import deque
from collections import defaultdict
import math
input = sys.stdin.readline
sys.setrecursionlimit(20000000)
h,w = map(int,input().split())
s = []
for i in range(h):
        a = [i for i in input().rstrip()]
        s.append(a)
ans = [[1]*w for i in range(h)]
res = 0
for i in range(h):
        res = 0
        for j in range(w):
                if s[i][j] == "." and 0<j and s[i][j-1] == ".":
                        res = res +1
                if s[i][j] == ".":
                        ans[i][j] += res
                else:
                        res = 0

res = 0
for i in range(h):
        res = 0
        for j in range(w-1,-1,-1):
                if s[i][j] == "." and w-1>j and s[i][j+1] == ".":
                        res = res +1
                if s[i][j] == ".":
                        ans[i][j] += res
                else:
                        res = 0
res = 0
for i in range(w):
        res = 0
        for j in range(h-1,-1,-1):
                if s[j][i] == "." and h-1>j and s[j+1][i] == ".":
                        res = res+1
                if s[j][i] == ".":
                        ans[j][i] += res
                else:
                        res = 0
res = 0
for i in range(w):
        res = 0
        for j in range(h):
                if s[j][i] == "." and 0<j and s[j-1][i] == ".":
                        res = res +1
                if s[j][i] == ".":
                        ans[j][i] += res           
                else:
                        res = 0  
ans2 = 0
for i in range(h):
        for j in range(w):
                ans2 = max(ans2,ans[i][j])
print(ans2)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**6)


def main():
    def dfs(now, prev=-1):
        for next in edge[now]:
            if next == prev:
                continue
            score[next] += score[now]
            dfs(next, now)

    N, Q = map(int, input().split())
    edge = [[] for _ in range(N+1)]
    for _ in range(N-1):
        u, v = map(int, input().split())
        edge[u].append(v)
        edge[v].append(u)
    p = []
    x = []
    score = [0] * (N+1)
    for _ in range(Q):
        p, x = map(int, input().split())
        score[p] += x
    dfs(1)
    print(*score[1:])


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 6)


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


def main():
    def dfs(now, prev=-1):
        for next in edge[now]:
            if next == prev:
                continue
            score[next] += score[now]
            dfs(next, now)

    N, Q = map(int, input().split())
    edge = [[] for _ in range(N+1)]
    for _ in range(N-1):
        u, v = map(int, input().split())
        edge[u].append(v)
        edge[v].append(u)
    p = []
    x = []
    score = [0] * (N+1)
    for _ in range(Q):
        p, x = map(int, input().split())
        score[p] += x
    dfs(1)
    print(*score[1:])


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

n = int(input())
a = list(map(int,input().split()))
b = sorted(a, reverse=True)
dp = [[0]*(n+1) for _ in range(n+1)]
ans = 0
def f(s,e):
  return abs(e-s)*a[s]
for i in range(n):
  d = a.index(b[i])
  for l in range(0,i+1):
    r = i-l
    dp[l+1][r] = max(dp[l+1][r], dp[l][r]+f(d,l))
    dp[l][r+1] = max(dp[l][r+1], dp[l][r]+f(d,n-r-1))
  a[d] = 0
for i in range(n+1):
  ans = max(ans, dp[i][n-i])
print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
b = sorted(a, reverse=True)
dp = [[0]*(n+1) for _ in range(n+1)]
ans = 0
def f(s,e):
  return abs(e-s)*a[s]
for i in range(n):
  d = a.index(b[i])
  for l in range(0,i+1):
    r = i-l
    dp[l+1][r] = max(dp[l+1][r], dp[l][r]+f(d,l))
    dp[l][r+1] = max(dp[l][r+1], dp[l][r]+f(d,n-r-1))
  a[d] = 0
for i in range(n+1):
  ans = max(ans, dp[i][n-i])
print(ans)
### BUGGY CODE ###

n,m=map(int,input().split())
import sys
sys.setrecursionlimit(10**7)

# Union FInd
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1] * n
  def find(self, x):
    if self.parents[x] < 0:
      return x
    else:
      self.parents[x] = self.find(self.parents[x])
      return self.parents[x]
  def union(self, x, y):
    x = self.find(x)
    y = self.find(y)
    if x == y:
      return
    if self.parents[x] > self.parents[y]:
      x, y = y, x
    self.parents[x] += self.parents[y]
    self.parents[y] = x
  def size(self, x):
    return -self.parents[self.find(x)]
  def same(self, x, y):
    return self.find(x) == self.find(y)
  def members(self, x):
    root = self.find(x)
    return [i for i in range(self.n) if self.find(i) == root]
  def roots(self):
    return [i for i, x in enumerate(self.parents) if x < 0]
  def group_count(self):
    return len(self.roots())
  def all_group_members(self):
    return {r: self.members(r) for r in self.roots()}
  def __str__(self):
    return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
uf=UnionFind(n)
for _ in range(m):
  a,b=map(int,input().split())
  a,b=a-1,b-1
  uf.union(a,b)
ans=0
d=uf.all_group_members()
for c in d.values():
  ans=max(ans,len(c))
print(ans)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)

N,Q = map(int,input().split())
par = [i for i in range(N)]
rank = [0]*(N+1)
def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x]) #経路圧縮
        return par[x]
def same(x,y):
    return find(x) == find(y)
def unite(x,y):
    x = find(x)
    y = find(y)
    if x == y:
        return 0
    if rank[x] < rank[y]:
        par[x] = y
    else:
        par[y] = x
        if rank[x]==rank[y]:rank[x]+=1

for _ in range(Q):
  a,b=map(int,input().split())
  a,b=a-1,b-1
  unite(a,b)
from collections import Counter
a=[-1]*N
for i in range(N):
  a[i]=find(i)
ca=Counter(a)
ans=0
for c in ca.values():
  ans=max(ans,c)
print(ans)
### BUGGY CODE ###

from collections import deque
N, X, Y = map(int, input().split())

K = [0 for _ in range(N)]
INF = 10 ** 9
def bfs(n):
    d = deque()
    d.append(n)
    reached = [INF for _ in range(N)]
    reached[n] = 0
    dx = [-1, 1]
    while d:
        x = d.popleft()
        for i in range(2):
            nx = x + dx[i]
            if nx < 0 or nx > N - 1 or reached[nx] != INF:
                continue
            d.append(nx)
            reached[nx] =reached[x] + 1
        if x == X-1 and reached[Y-1] == INF:
            reached[Y-1] = reached[x] + 1
            d.append(Y-1)
        if x == Y-1 and reached[X-1] == INF:
            reached[X-1] = reached[x] + 1
            d.append(X-1)
    for i in range(N):
        K[reached[i]] += 1            

for i in range(N):
    bfs(i)

for i in range(len(K)):
    K[i] = K[i] // 2

for i in range(1, len(K)):
    print(K[i])

### FIXED CODE ###

from collections import deque
N, X, Y = map(int, input().split())

K = [0 for _ in range(N)]
INF = 10 ** 9
def bfs(n):
    d = deque()
    d.append(n)
    reached = [INF for _ in range(N)]
    reached[n] = 0
    dx = [-1, 1]
    while d:
        x = d.popleft()
        for i in range(2):
            nx = x + dx[i]
            if nx < 0 or nx > N - 1 or reached[nx] != INF:
                continue
            d.append(nx)
            reached[nx] =reached[x] + 1
        if x == X-1 and reached[Y-1] == INF:
            reached[Y-1] = reached[x] + 1
            d.append(Y-1)
        if x == Y-1 and reached[X-1] == INF:
            reached[X-1] = reached[x] + 1
            d.append(X-1)
    for i in range(N):
        K[reached[i]] += 1            

for i in range(N):
    bfs(i)

for i in range(1, N):
    print(K[i]//2)
### BUGGY CODE ###

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

def main():
    N,W = map(int,input().split())
    X = [list(map(int,input().split())) for _ in range(N)]
    dp = [[0 for _ in range(W+1)] for _ in range(N+1)]
    for i in range(N):
        for w in range(W+1):
            if X[i][0] <= w:
                dp[i+1][w] = max(dp[i][w-X[i][0]]+X[i][1],dp[i+1][w])
            else:
                dp[i+1][w] = dp[i][w]
    dp = np.array(dp)
    print(dp.max())

if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
input = sys.stdin.readline

def main():
    N,W = map(int,input().split())
    dp = [-1 for _ in range(W+1)]
    dp[W] = 0
    for _ in range(N):
        nm,nv = [int(a) for a in input().split()]
        for j in range(nm,W+1):
            a = nm
            if dp[j] == -1:
                continue
            if dp[j-a] < dp[j] + nv:
                dp[j-a] = dp[j] + nv
    print(max(dp))

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

n, c = map(int, input().split())
X = []
V = []
right = []
rightleft = []
calsum = 0
for i in range(n):
    x, v = map(int, input().split())
    X.append(x)
    V.append(v)
    calsum += v
    right.append(calsum-x)
    rightleft.append(calsum-2*x)

left = []
leftright = []
calsum = 0
results = []
for i in range(n):
    calsum += V[n-i-1]
    left.append(calsum - (c-X[n-i-1]))
    leftright.append(calsum - 2*(c-X[n-i-1]))

rl = []
for i, v in enumerate(rightleft):
    if n-i > 1:
        rl.append(max(left[:n-i-1]) + v)

lr = []
for i, v in enumerate(leftright):
    if n-i > 1:
        lr.append(max(right[:n-i-1]) + v)

result = max(max(right), max(left), 0)
if len(rl) > 0:
    result = max(result, max(rl))
if len(lr) > 0:
    result = max(result, max(lr))
print(result)


### FIXED CODE ###

n, c = map(int, input().split())
X = []
V = []
right = []
rightleft = []
calsum = 0
for i in range(n):
    x, v = map(int, input().split())
    X.append(x)
    V.append(v)
    calsum += v
    right.append(calsum-x)
    rightleft.append(calsum-2*x)

left = []
leftright = []
calsum = 0
for i in range(n):
    calsum += V[n-i-1]
    left.append(calsum - (c-X[n-i-1]))
    leftright.append(calsum - 2*(c-X[n-i-1]))

m = 0
M = 0
for i in range(0, n-1):
    m = max(m, left[i])
    M = max(M, m + rightleft[n-i-2])

mm = 0
MM = 0
for i in range(0, n-1):
    mm = max(mm, right[i])
    MM = max(MM, mm + leftright[n-i-2])

print(max(max(right), max(left), M, MM, 0))
### BUGGY CODE ###

class LinkedList(object):
    def __init__(self):
        self.first = None
        self.last = None

    def insert(self, key):
        if not self.first:
            self.first = self.last = {'key':key, 'next':None, 'prev':None}
        else:
            self.first = {'key':key, 'next':self.first, 'prev':None}
            self.first['next']['prev'] = self.first

    def delete(self, key):
        node = self.first
        if self.first['key'] == key:
            self.deleteFirst()
            return
        while node['next']:
            if node['key'] == key:
                node['prev']['next'] = node['next']
                node['next']['prev'] = node['prev']
                return
            node = node['next']
        if self.last['key'] == key:
            self.deleteLast()

    def deleteFirst(self):
        if self.first == self.last:
            self.first = self.last = None
        else:
            self.first = self.first['next']
            self.first['prev'] = None

    def deleteLast(self):
        if self.first == self.last:
            self.first = self.last = None
        else:
            self.last = self.last['prev']
            self.last['next'] = None

    def show(self):
        if not self.first:
            print('')
            return
        node = self.first
        res = [node['key']]
        while node['next']:
            node = node['next']
            res.append(node['key'])
        print(' '.join(res))

def run():
    n = int(input())
    linked_list = LinkedList()
    for _ in range(n):
        order = input()
        if order.startswith('insert'):
            linked_list.insert(order.split()[1])
        elif order.startswith('deleteFirst'):
            linked_list.deleteFirst()
        elif order.startswith('deleteLast'):
            linked_list.deleteLast()
        elif order.startswith('delete'):
            linked_list.delete(order.split()[1])
    linked_list.show()

if __name__ == '__main__':
    run()




### FIXED CODE ###

from collections import deque

def run():
    n = int(input())
    dq = deque()
    for _ in range(n):
        order = input()
        if order[0] == 'i':
            dq.appendleft(order[7:])
        elif order[6] == ' ':
            key = order.split()[1]
            if not key in dq:
                continue
            for i in range(len(dq)):
                if dq[i] == key:
                    dq.remove(key)
                    break
        elif order[6] == 'F':
            dq.popleft()
        elif order[6] == 'L':
            dq.pop()

    print(' '.join(dq))

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

def main():
  from functools import reduce
  ans = 0
  n = int(input())
  b = tuple(map(int, input().split()))
  b_ = tuple(set(b))
  ov = 10**9+7
  from fractions import gcd
  def lcm(x,y):
    return (x * y) // gcd(x, y)
  def lcm_list(a):
    return reduce(lcm, a, 1)
  l = lcm_list(b_)
  for i in b:
    ans += l//i%ov
  print(ans%ov)
if __name__ == "__main__":
  main()


### FIXED CODE ###

def main():
  from functools import reduce
  from fractions import gcd
  ans = 0
  n = int(input())
  b = tuple(map(int, input().split()))
  ov = 10**9+7
  def lcm(x,y):
    return (x * y) // gcd(x, y)
  def lcm_list(a):
    return reduce(lcm, a, 1)
  l = lcm_list(b)
  for i in range(n):
    ans += l//b[i]
  print(ans%ov)
if __name__ == "__main__":
  main()
### BUGGY CODE ###

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

for j in range(q):
  for i in range(n):
    if a[i]==bc[j][0]:
      a[i]=bc[j][1]
  print(sum(a))

### FIXED CODE ###

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

asum=sum(a) #当初の数列Aの要素の和
d={}

for i in a:
  if i in d:
    d[i]+=1
  else:
    d[i]=1

for b,c in bc:
  if b in d:
    asum+=d[b]*(c-b)
    if c in d:
      d[c]+=d[b]
    else:
      d[c]=d[b]
    d[b]=0
  print(asum)
### BUGGY CODE ###

N, M = map(int, input().split())
L = []
P = []
#Y = []
var = []
for i in range(M):
    p, y = map(int, input().split())
    if p not in P:
        var.append(p)
    P.append(p)
    #Y.append(y)
    L.append([i, p, y])

#L = list(zip(range(M), P, Y))     

Order = [None]*M

for v in var:
    #l = filter(lambda x:x[1] == v, L)
    l_ = sorted(filter(lambda x:x[1] == v, L), key = lambda x:x[2])
    
    for n in l_:
        Order[n[0]] = (n[1], l_.index(n)+1)
        
for n in Order:
    print('{0:0>6d}{1:0>6d}'.format(n[0], n[1]))

### FIXED CODE ###

N, M = map(int, input().split())
L = []
P = [0]*(N+1)
for i in range(M):
    p, y = map(int, input().split())
    L.append([i, p, y, 0])

L = sorted(L, key = lambda x:x[2])

for l in L:
    P[l[1]] += 1
    l[3] = P[l[1]]    
        
for l in sorted(L, key = lambda x:x[0]):
    print('{0:0>6d}{1:0>6d}'.format(l[1], l[3]))
### BUGGY CODE ###

N,K = map(int,input().split())
p_list = list(map(int,input().split()))
ans_list = []
def E(me):
    if me == 1:
        return 1
    else:
        return ((1+me)*me/2)/me
E_list = [E(i) for i in p_list]
ans = 0
for i in range(N-K+1):
    ans = max(sum(E_list[i:i+K]),ans)
print(ans)


### FIXED CODE ###

N,K = map(int,input().split())
p_list = list(map(int,input().split()))
ans_list = []
def E(me):
    if me == 1:
        return 1
    else:
        return ((1+me)*me/2)/me
E_list_ruisekiwa = [0,]
for i in range(N):
    E_list_ruisekiwa.append(E_list_ruisekiwa[i]+E(p_list[i]))

ans = 0
for i in range(N-K+1):
    ans = max(E_list_ruisekiwa[i+K]-E_list_ruisekiwa[i],ans)
print(ans)
### BUGGY CODE ###

n = int(input())
syain = list(map(int,input().split()))
for i in range(n):
  print(syain.count(i+1))

### FIXED CODE ###

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

b = [0]*(n+2)

for i in range(n-1):
  b[a[i]] += 1
  
for i in range(1,n+1):
  print(b[i])