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

def solve():
    ans = [-float('inf'),0]
    mod = 10**9+7
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    minus = []
    plus = []
    for i in range(N):
        if A[i]>=0:
            plus.append(A[i])
        else:
            minus.append(A[i])
    plus.sort()
    minus.sort(reverse=True)
    p = len(plus)
    m = len(minus)
    plus_large = [[0,1] for _ in range(p+1)]
    plus_small = [[0,1] for _ in range(p+1)]
    minus_large = [[0,1] for _ in range(m+1)]
    minus_small = [[0,1] for _ in range(m+1)]
    for i in range(p):
        plus_large[i+1][1] = plus_large[i][1]*plus[p-i-1]%mod
        plus_large[i+1][0] = plus_large[i][0]*plus[p-i-1]+plus_large[i][1]*plus[p-i-1]//mod
        plus_small[i+1][1] = plus_small[i][1]*plus[i]%mod
        plus_small[i+1][0] = plus_small[i][0]*plus[i]+plus_small[i][1]*plus[i]//mod
    for i in range(m):
        minus_large[i+1][1] = minus_large[i][1]*minus[m-i-1]%mod
        minus_large[i+1][0] = minus_large[i][0]*minus[m-i-1]+minus_large[i][1]*minus[m-i-1]//mod
        minus_small[i+1][1] = minus_small[i][1]*minus[i]%mod
        minus_small[i+1][0] = minus_small[i][0]*minus[i]+minus_small[i][1]*minus[i]//mod
    
    for mi in range(K+1): 
        pl = K-mi
        if p>=K-mi and m>=mi:
            if mi%2==0: #正の数
                a,b = plus_large[pl]
                c,d = minus_large[mi]
            else: #負の数
                a,b = plus_small[pl]
                c,d = minus_small[mi]
            f = b*d%mod
            e = a*c*mod + b*c + a*d + b*d//mod
            if e>ans[0] or (e==ans[0] and f>ans[1]):
                ans = [e,f]
    return ans[1]
print(solve())

### FIXED CODE ###

from collections import defaultdict
def prod(A,k,mod):
  ans = 1
  for i in range(k):
      ans *= A[i]
      ans %= mod
  return ans
def solve():
  N, K = map(int, input().split())
  A = list(map(int, input().split()))
  mod = 10**9+7
  ans = 1
  if K==N:
    return prod(A,N,mod)
  minus = len([a for a in A if a<0])
  if minus==N:
    if K%2==0:
      A.sort()
    else:
      A.sort(reverse=True)
    return prod(A,K,mod)
  if K==1:
    return max(A)
  A.sort(key=lambda x:-abs(x))
  if A[K]==0:
    return 0
  minus = len([a for a in A[:K] if a<0])
  flag = [1]*K+[0]*(N-K)
  d = defaultdict(lambda: -1)
  if minus%2==1:
    for i in range(K,N):
      if A[i]>=0:
        d['p2'] = i
        break
    for i in range(K,N):
      if A[i]<0:
        d['m2'] = i
        break
    for i in range(K-1,-1,-1):
      if A[i]>0:
        d['p1'] = i
        break
    for i in range(K-1,-1,-1):
      if A[i]<0:
        d['m1'] = i
        break
    if d['p2']==-1 or d['m1']==-1:
      flag[d['m2']],flag[d['p1']] = 1,0
    elif d['m2']==-1 or d['p1']==-1:
      flag[d['p2']],flag[d['m1']] = 1,0
    elif A[d['p2']]*A[d['p1']]>A[d['m1']]*A[d['m2']]:
        flag[d['p2']],flag[d['m1']] = 1,0
    else:
      flag[d['m2']],flag[d['p1']] = 1,0
    ans = 1
    for i in range(N):
      if flag[i]==1:
        ans *= A[i]
        ans %= mod
    return ans
  return prod(A,K,mod)
print(solve())
### BUGGY CODE ###

N,K,*A = map(int,open(0).read().split())

for i in range(K):
    after = [0] * N 
    for a in range(N):
        if A[a] == 0:
            after[a] += 1
        else:
            left = max(0,a-A[a])
            right = min(a+A[a],N-1)
            for aa in range(left, right+1):
                after[aa] += 1
    A = after[:]                
print(*after,sep=" ")                    
                
        

### FIXED CODE ###

from itertools import accumulate
#from operator import add

N,K = map(int,input().split())
A = map(int,input().split()) 
for k in range(K):
    B = [0] * N
    for i,x in enumerate(A):
        L = max(0, i-x)
        R = min(N-1, i+x)
        B[L] += 1
        if R+1 != N:
            B[R+1] -= 1
    #L = accumulate(B,add) 
    L = list(accumulate(B))[:]
    if L == A:
        break
    A = L
print(*A)
### BUGGY CODE ###

if __name__ == '__main__':
    n, m = map(int, input().split())
    shops = []
    ans = 0
    for i in range(n):
        shops.append(list(map(int, input().split())))
        shops.sort(key=lambda x:x[0])

    for shop in shops:
        price = shop[0]
        available = shop[1]
        if m - available > 0:
            ans += price * available
            m -= available
        else:
            ans += price * m
            break

    print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline


if __name__ == '__main__':
    n, m = map(int, input().split())
    shops = []
    ans = 0
    for i in range(n):
        shops.append(list(map(int, input().split())))
    shops.sort(key=lambda x:x[0])

    for shop in shops:
        price = shop[0]
        available = shop[1]
        if m - available > 0:
            ans += price * available
            m -= available
        else:
            ans += price * m
            break

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

def main():

    S = []
    S = input()
    Q = int(input())
    query = [None]*Q
    for i in range(Q):
        query[i] = input()
        
    rev = 0
    for q in query:
        if q[0] == "1":
            rev = (rev+1)%2
        else:
            if q[2] == "1":
                if rev == 0:
                    S = "".join([q[4], S])
                    #S = q[4] + S
                else:
                    S = "".join([S, q[4]])
                    #S = S + q[4]
            else:
                if rev ==0:
                   S = "".join([S, q[4]])
                else:
                    S = "".join([q[4], S])
    if rev == 1:
        S = S[::-1]

    print(S)

main()

### FIXED CODE ###

from sys import stdin

def main():
    S = list(stdin.readline().rstrip())
    Q = int(input())
    rev = 0
    head = []
    tail = []

    for _ in range(Q):
        q = stdin.readline()
        if q[0] == "1":
            rev = (rev+1)%2
        else:
            if q[2] == "1":
                if rev == 0:
                    head.append(q[4])
                else:
                    tail.append(q[4])
            else:
                if rev ==0:
                    tail.append(q[4])
                else:
                    head.append(q[4])

    if rev == 0:
        ans = "".join(head[::-1] + S + tail)
    else:
        ans = "".join(tail[::-1] + S[::-1] + head)
    
    print(ans)
    """
    S = stdin.readline().rstrip() 
    Q = int(input())
    rev = 0
    for _ in range(Q):
        q = stdin.readline()

        if q[0] == "1":
            rev = (rev+1)%2
        else:
            if q[2] == "1":
                if rev == 0:
                    S = "{}{}".format(q[4], S)
                else:
                    S = "{}{}".format(S, q[4])
            else:
                if rev ==0:
                    S = "{}{}".format(S, q[4])
                else:
                    S = "{}{}".format(q[4], S)
    if rev == 1:
        print(S[::-1])
    else:
        print(S)
    """
main()
### BUGGY CODE ###

import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = list(map(int, input().split()))

    res = 1
    for a in A:
        res *= a

    print(res if res <= 10 ** 18 else -1)


if __name__ == '__main__':
    resolve()


### FIXED CODE ###

import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = sorted(list(map(int, input().split())))

    res = 1
    for a in A:
        res *= a
        if res > 10 ** 18:
            print(-1)
            break
    else:
        print(res)


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

import numpy as np

from sys import stdin


def main():
    n = int(stdin.readline())
    a = list(map(int, stdin.readline().split()))

    a2 = [[a[i], i] for i in range(n)]
    a2.sort(reverse=True)

    dp = [[0 for _ in range(n + 1)] for _ in range(n + 1)]

    ans = 0

    for i in range(n + 1):
        for j in range(n + 1 - i):
            s1 = s2 = 0
            if i > 0:
                s1 = dp[i - 1][j] + a2[i + j - 1][0] * (a2[i + j - 1][1] - (i - 1))
            if j > 0:
                s2 = dp[i][j - 1] + a2[i + j - 1][0] * ((n - j) - a2[i + j - 1][1])
            dp[i][j] = np.max([s1, s2])
        ans = np.max([ans, dp[i][n - i]])

    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

from sys import stdin


def main():
    n = int(stdin.readline())
    a = list(map(int, stdin.readline().split()))

    a2 = [[a[i], i] for i in range(n)]
    a2.sort(reverse=True)

    dp = [[0 for _ in range(n + 1)] for _ in range(n + 1)]

    ans = 0

    for i in range(n + 1):
        for j in range(n + 1 - i):
            s1 = s2 = 0
            if i > 0:
                s1 = dp[i - 1][j] + a2[i + j - 1][0] * (a2[i + j - 1][1] - (i - 1))
            if j > 0:
                s2 = dp[i][j - 1] + a2[i + j - 1][0] * ((n - j) - a2[i + j - 1][1])
            dp[i][j] = max(s1, s2)
        ans = max(ans, dp[i][n - i])

    print(ans)


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

from math import floor
a, b, n = map(int, input().split())

ans = 0
for x in range(0, n + 1):
    ans = max(floor(a * x / b) - a * floor(x / b), ans)
    if ans > floor(a * x / b) - a * floor(x / b):
        break
print(ans)

### FIXED CODE ###

from math import floor

a, b, n = map(int, input().split())
x = min(b - 1, n)
print(floor(a * x / b) - a * floor(x / b))
### BUGGY CODE ###

#!/usr/bin/env pypy3
# N,M = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(int(sys.stdin.readline()) for _ in range(N)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# N = int(sys.stdin.readline())
# INF = float("inf")
import math,sys

n = int(sys.stdin.readline())
a = tuple(map(int,sys.stdin.readline().split()))
#n = int(input())
#a = list(map(int,input().split()))
g = math.gcd(a[0],a[1])
for i in range(2,n):
    g = math.gcd(g,a[i])
M = max(a)
acc = a[0]
for i in range(n):
    acc = math.gcd(acc,a[i])
if acc != 1:
    print("not coprime")
    exit()

LIMIT=max(a)
minPrime = [0]*(LIMIT+1)
minPrime[1] = 1
def make():
    for i in range(2,LIMIT+1):
        if minPrime[i] == 0:
            minPrime[i] = i
            #print(i)
            for j in range(i+i,LIMIT+1,i):
                #print(i,j)
                if minPrime[j] == 0:
                    minPrime[j] = i
make()
def factrial(N):
     ret = []
     while minPrime[N] != N:
         ret.append(minPrime[N])
         N = N//minPrime[N]
     if N != 1:
         ret.append(N)
     return ret

judge = set([])

for e in a:
    asf = set(factrial(e))
    if judge & asf != set():
        print("setwise coprime")
        exit()
    #judge |= asf
    judge = judge | asf #too slow
print("pairwise coprime")

### FIXED CODE ###

import math
from collections import defaultdict
pc = True
n = int(input())
a = list(map(int,input().split()))
g = math.gcd(a[0],a[1])
for i in range(2,n):
    g = math.gcd(g,a[i])
M = max(a)
class Sieve_of_Eratosthenes:
    def __init__(self, N):
        self.sieve = [-1] * (N+1)
 
        for i in range(2,N+1):
            if self.sieve[i] == -1:
                for j in range(1,1+N//i):
                    self.sieve[i*j] = i
 
    def isprime(self, num):
        if num <= 1:
            return False
        else:
            return self.sieve[num] == num
 
    def factorization(self, num):
        ret = set([])
        while num != 1:
            div = self.sieve[num]
            ret.add(div)
            num //= div
        return ret
 
sofe = Sieve_of_Eratosthenes(M)
ddic = defaultdict()
judge = set([])
 
for i in a:
    if not pc:
        break
    asf = sofe.factorization(i)
    
    if judge & asf != set():
        pc = False
    judge |= asf
if pc:
    print("pairwise coprime")
elif g == 1:
    print("setwise coprime")
else:
    print("not coprime")
### BUGGY CODE ###

n = input()
nums = map(int, input().split())
 
num_dvd = 0

can_devide = True
temp_list = []
while can_devide == True:
  for num in nums:
    if num % 2 == 1:
      print(num_dvd)
      can_devide == False
    else:
      temp_list.append(num // 2)
  num_dvd += 1
  nums, temp_list = temp_list, []

### FIXED CODE ###

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

num_dvd = 0
 
can_devide = True
temp_list = []
while can_devide:
  for num in nums:
    if num % 2 == 1:
      can_devide = False
      print(num_dvd)
      break
    else:
      temp_list.append(num // 2)
  num_dvd += 1
  nums, temp_list = temp_list, []
### BUGGY CODE ###

N, M, R = map(int, input().split())
R_LIST = list(map(int, input().split()))
ABC = []
for _ in range(M):
    a,b,c = map(int, input().split())
    ABC.append((a,b,c))
edges = ABC[:]


def warshall_floyd(d, n):
    # d: グラフ二次元リスト
    # n: 頂点数 (0始まり)
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

# グラフ無効グラフ化
graph = [[float("inf") for i in range(N)] for i in range(N)] 
for x,y,z in edges:
    graph[x-1][y-1] = z
    graph[y-1][x-1] = z
for i in range(N):
    graph[i][i] = 0 #自身のところに行くコストは０

#最短経路
shortest =  warshall_floyd(graph, N)
    
# 順列全探索
import sys
INT_MAX = sys.maxsize # 9223372036854775807
ans = INT_MAX

import itertools
line = R_LIST
for l in itertools.permutations(line):
    #print(l)
    tmp_len = 0
    for a,b in zip(l[:-1], l[1:]):
        tmp_len += shortest[a-1][b-1]

    #print(tmp_len)
    ans = min(ans, tmp_len)
print(ans)

### FIXED CODE ###

N, M, R = map(int, input().split())
R_LIST = list(map(int, input().split()))
ABC = []
for _ in range(M):
    a,b,c = map(int, input().split())
    ABC.append((a,b,c))
    
    
edges = ABC[:]


def warshall_floyd(d, n):
    # d: グラフ二次元リスト
    # n: 頂点数 (0始まり)
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

# グラフ無効グラフ化
graph = [[float("inf") for i in range(N+1)] for i in range(N+1)] 
for x,y,z in edges:
    graph[x][y] = z
    graph[y][x] = z
for i in range(N+1):
    graph[i][i] = 0 #自身のところに行くコストは０

#最短経路
shortest =  warshall_floyd(graph, N+1)
    
# 順列全探索
import sys
INT_MAX = sys.maxsize # 9223372036854775807
ans = INT_MAX

import queue

rest = set(R_LIST[:])

import copy  
def dfs(cost,pre,rest):
    if len(rest) == 0:
        return cost
    
    ret = INT_MAX
    for r in rest:
        if pre == None:
            next_cost = 0
        else:
            next_cost = cost + shortest[pre][r]
        next_rest = copy.copy(rest)
        next_rest.remove(r)
        
        tmp_ret = dfs(next_cost, r, next_rest)
        ret = min(ret, tmp_ret)
        
    return ret
        
    

print(dfs(0, None, rest))
### BUGGY CODE ###

N = int(input())

nums = []
for i in range(N):
    nums.append(int(input()))

for i in range(N):
    print(max(nums[i+1:]+nums[:i]))

### FIXED CODE ###

N = int(input())

nums = [int(input()) for i in range(N)]
first = sorted(nums)[-1]
second = sorted(nums)[-2]

for i in range(N):
    if nums[i] == first:
        print(second)
    else:
        print(first)
### BUGGY CODE ###

N = int(input())
S = []
for i in range(N):
    S.append(input())
    S[i] = list(S[i])
    S[i].sort()
    S[i] = "".join(S[i])

ans = 0

for i in range(N):
    for j in range(i+1, N):
        if S[i] == S[j]:
            ans += 1

print(ans)

### FIXED CODE ###

from collections import Counter
from math import factorial
N = int(input())
S = []
for i in range(N):
    tmp = input()
    tmp = sorted(list(tmp))
    S.append("".join(tmp))

cnt = Counter(S)
ans = 0
for i in cnt:
    if cnt[i] > 1:
        ans += factorial(cnt[i]) // (factorial(cnt[i] - 2) * factorial(2))

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

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

count = 0
for k in range(min(d_list), max(d_list) + 1):
    ABC = 0
    ARC = 0
    for i in range(N):
        if k > d_list[i]:
            ABC += 1
        else:
            ARC += 1
    if ABC > ARC:
        break
    elif ABC == ARC:
        count += 1
    else:
        pass

print(count)
        

### FIXED CODE ###

N = int(input())
d_list = list(map(int, input().split()))
d_list.sort()

k = d_list[int(N/2)]
count = 0
for i in range(N):
    if count == int(N/2):
        print(d_list[int(N/2)] - d_list[int(N/2)-1])
        break
    elif k > d_list[i]:
        count += 1
    else:
        pass
else: # kの候補の右端は必ずd_listの中
    print(0)
### BUGGY CODE ###

from bisect import bisect_left
N = int(input())
A = sorted(list(map(int,input().split())))
cnt = 0
hist = [0 for _ in range(N)]
for i in range(N-1,0,-1):
    if hist[i]==0:
        a = A[i]
        k = 0
        while 2**k<=a:
            k += 1
        b = 2**k-a
        ind = bisect_left(A[:i],b)
        if ind<i and hist[ind]==0:
            hist[i]=1
            hist[ind]=1
            cnt += 1
        elif ind<i and hist[ind]==1:
            ind += 1
            while A[ind]==b:
                if hist[ind]==0:
                    hist[i]=1
                    hist[ind]=1
                    cnt += 1
                    break
print(cnt)

### FIXED CODE ###

from bisect import bisect_left
N = int(input())
A = sorted(list(map(int,input().split())))
A = [[A[i],0] for i in range(N)]
cnt = 0
for i in range(N-1,0,-1):
    if A[i][1]==0:
        a = A[i][0]
        A[i][1]=1
        k = 0
        while 2**k<=a:
            k += 1
        b = 2**k-a
        ind = bisect_left(A,[b,1])
        ind -= 1
        if ind<i and A[ind]==[b,0]:
            A[ind][1]=1
            cnt += 1
print(cnt)
### BUGGY CODE ###

import sys
import collections


def solve():
    sys.setrecursionlimit(2000)
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    h, w = list(map(int, input().rstrip('\n').split()))
    a = [list(str(input().rstrip('\n'))) for _ in range(h)]
    ql = []
    ql = collections.deque(ql)
    fq = collections.defaultdict(list)
    for i in range(h):
        for j in range(w):
            if a[i][j] == "#":
                ql.append([0, i, j, [[0, 1], [0, -1], [1, 0], [-1, 0]]])
                fq[i, j]

    while True:
        if len(ql) != 0:
            cost, xv, yv, nextv = ql.popleft()
            for nxv, nyv in nextv:
                if 0 <= xv + nxv < h and 0 <= yv + nyv < w:
                    if (xv + nxv, yv + nyv) not in fq:
                        fq[xv + nxv, yv + nyv]
                        if nxv == 1:
                            ql.append([cost + 1, xv + nxv, yv + nyv, [[0, 1], [0, -1], [1, 0]]])
                        elif nxv == -1:
                            ql.append([cost + 1, xv + nxv, yv + nyv, [[0, 1], [0, -1], [-1, 0]]])
                        elif nyv == 1:
                            ql.append([cost + 1, xv + nxv, yv + nyv, [[-1, 0], [1, 0], [0, 1]]])
                        elif nyv == -1:
                            ql.append([cost + 1, xv + nxv, yv + nyv, [[-1, 0], [1, 0], [0, -1]]])
        else:
            break
    print(cost)


if __name__ == '__main__':
    solve()


### FIXED CODE ###

import sys
import collections


def solve():
    readline = sys.stdin.buffer.readline
    h, w = list(map(int, readline().split()))
    a = [[True] * w for _ in range(h)]
    ql = collections.deque()
    for i in range(h):
        s = list(str(readline().rstrip().decode('utf-8')))
        for j in range(w):
            if s[j] == "#":
                ql.append([0, i, j])
                a[i][j] = False
    while ql:
        cost, x, y = ql.popleft()
        for xv, yv in ((x + 1, y), (x - 1, y), (x, y + 1), (x, y - 1)):
            if 0 <= xv < h and 0 <= yv < w:
                if a[xv][yv]:
                    ql.append([cost + 1, xv, yv])
                    a[xv][yv] = False
    print(cost)


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

def main():
    import bisect
    import sys
    from itertools import accumulate
    input = sys.stdin.readline
    def hsnum(ls,x,n):
        num = 0
        for i in range(n):
            y = x-ls[i]
            num += n-bisect.bisect_left(ls,y)
        return num
    n,m = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort()
    a = tuple(a)
    suma = [0]+list(accumulate(a))
    lx = 0
    rx = 2*10**5+2
    error = 0
    while lx < rx:
        mx = (lx+rx)//2
        if hsnum(a,mx,n) < m:
            rx = mx
        elif hsnum(a,mx,n) > m:
            if hsnum(a,mx+1,n) < m:
                error = hsnum(a,mx,n)-m
                lx = mx
                break
            lx = mx + 1
        else:
            lx = mx
            break
    ans = 0
    for i in range(n):
        rema = lx - a[i]
        j = bisect.bisect_left(a,rema)
        ans += (n-j)*a[i]+suma[n]-suma[j]
    print(ans-error*lx)
if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
  import bisect
  import sys
  from itertools import accumulate
  input = sys.stdin.readline
  def hsnum(x):
    num = 0
    for i in a:
      y = x-i
      num += n-bisect.bisect_left(a,y)
    return num
  n,m = map(int, input().split())
  a = list(map(int, input().split()))
  a.sort()
  suma = [0]+list(accumulate(a))
  lx = 0
  rx = 2*10**5+2
  error = 0
  while lx+1 < rx:
    mx = (lx+rx)//2
    if hsnum(mx) < m:
      rx = mx
    elif hsnum(mx) > m:
      lx = mx + 1
    else:
      lx = mx
      break
  if hsnum(lx)<m:
    lx -= 1
  error = hsnum(lx)-m
  ans = 0
  for i in a:
    rema = lx - i
    j = bisect.bisect_left(a,rema)
    ans += (n-j)*i-suma[j]
  ans += suma[n]*n
  print(ans-error*lx)
if __name__ == "__main__":
    main()
### BUGGY CODE ###

from math import gcd
def INT(): return int(input())
 
 
K = INT()
sum = 0
 
for n in range(K):
  for m in range(K):
    for l in range(K):
      sum += gcd(gcd(n+1, m+1), l+1)
 
print(sum)

### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
K = INT()
sum = 0
 
for n in range(K):
  for m in range(K):
    for l in range(K):
      sum += gcd(n+1, gcd(m+1, l+1))
 
print(sum)
### BUGGY CODE ###

H, W, N = map(int, input().split())
ab = []
for i in range(N):
    a, b = map(int, input().split())
    ab.append((a - 1, b - 1))

comb_map = {}
if N >= 1:
    for i in range(0, H - 2):
        for j in range(0, W - 2):
            comb_map[(i, j)] = 0

    for a, b in ab:
        for k in range(3):
            for m in range(3):
                if 0 <= a - k < H - 2 and 0 <= b - m < W - 2:
                    comb_map[(a - k, b - m)] += 1

count = [0 for _ in range(10)]

for v in comb_map.values():
    count[v] += 1

count[0] = (H - 2) * (W - 2) - sum(count[1:])

for c in count:
    print(c)


### FIXED CODE ###

H, W, N = map(int, input().split())
ab = []
for i in range(N):
    a, b = map(int, input().split())
    ab.append((a - 1, b - 1))

comb_map = {}


for a, b in ab:
    for k in range(3):
        for m in range(3):
            if 0 <= a - k < H - 2 and 0 <= b - m < W - 2:
                if (a-k, b-m) in comb_map.keys():
                    comb_map[(a - k, b - m)] += 1
                else:
                    comb_map[(a - k, b - m)] = 1

count = [0 for _ in range(10)]

for v in comb_map.values():
    count[v] += 1

count[0] = (H - 2) * (W - 2) - sum(count[1:])

for c in count:
    print(c)