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

from numpy import sqrt
N,P = map(int,input().split(" "))

ans = 1
for i in range(1,int(sqrt(P))+1):
    if P % i == 0:
        if P % pow(i,N) == 0:
            ans = max(i,ans)
        if P  % pow((P//i),N) == 0:
            ans = max(P//i,ans)

print(ans)

### FIXED CODE ###

from numpy import sqrt
N,P = map(int,input().split(" "))
lm = pow(P,1/N) + 0.5
if N == 1:
    print(P)
    exit(0)

ans = 1
for i in range(1,int(sqrt(P))+10):
    if P % i == 0:
        if i <= lm and P % pow(i,N) == 0:
            ans = max(i,ans)
        if (P//i) <= lm and P % pow((P//i),N) == 0:
            ans = max(P//i,ans)

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

# coding: utf-8
from collections import deque
def main():
    N, X, Y = map(int, input().split())
    X -= 1
    Y -= 1
    D = [[0 for _ in range(N)] for _ in range(N)]
    D[X][Y] = 1
    D[Y][X] = 1
    queue = deque([[X, Y]])
    visited = [[False for _ in range(N)] for _ in range(N)]
    visited[X][Y] = True 
    ans = [0 for _ in range(N)]
    while queue:
        x,y = queue.popleft()
        for i, j in zip([1, 0, -1, 0], [0, 1, 0, -1]):
            nx, ny = x+i, y+j
            if nx < 0 or nx >= N or ny < 0 or ny >= N:
                continue
            if visited[nx][ny]:
                continue
            else:
                visited[nx][ny] = True
                D[nx][ny] = min(abs(ny-nx), D[x][y]+1)
                queue.append([nx, ny])
    cnt = 0
    for i in range(N):
        for j in range(i+1, N):
            v = D[i][j]
            ans[v-1] += 1
    print(*ans[:-1], sep="\n")
main()

### FIXED CODE ###

# coding: utf-8
from collections import deque
N, X, Y = map(int, input().split())
X -= 1
Y -= 1
D = [[0 for _ in range(N)] for _ in range(N)]
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        D[i][j] = abs(j-i)
        D[j][i] = abs(j-i)
D[X][Y] = 1
D[Y][X] = 1
# print(*D, sep="\n")
queue = deque([[X, Y]])
visited = [[False for _ in range(N)] for _ in range(N)]
visited[X][Y] = True 
while queue:
    x,y = queue.popleft()
    for i, j in zip([1, 0, -1, 0], [0, 1, 0, -1]):
        nx, ny = x+i, y+j
        if nx < 0 or nx >= N or ny < 0 or ny >= N:
            continue
        if visited[nx][ny]:
            continue
        else:
            visited[nx][ny] = True
            D[nx][ny] = min(D[nx][ny], D[x][y]+1)
            queue.append([nx, ny])
# print(*D, sep="\n")
ans = [0 for _ in range(N)]
cnt = 0
for i in range(N):
    for j in range(i+1, N):
        # cnt += 1
        v = D[i][j]
        # print(i,j, v)
        ans[v-1] += 1
print(*ans[:-1], sep="\n")
### BUGGY CODE ###

from collections import Counter

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

c = Counter(S)

l = list(filter(lambda v: v[1] == c.most_common()[0][1], c.most_common()))
l.sort()

for s in l:
    print(s[0])

### FIXED CODE ###

from collections import Counter

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

c = Counter(S).most_common()

l = list(filter(lambda v: v[1] == c[0][1], c))
l.sort()

a = l[0][1]
for s in l:
    if s[1] != a: break
    print(s[0])
### BUGGY CODE ###

import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    A = [list(map(int, input().split())) for _ in range(N)]

    INF = float('INF')
    for i in range(N):
        A[i][i] = INF

    ans = 0
    for i in range(N):
        for j in range(i):
            bipas = 10**9 + 1
            for k in range(N):
                bipas = min(bipas, A[i][k] + A[k][j])

            if A[i][j] > bipas:
                ans = -1
                break
            elif A[i][j] < bipas:
                ans += A[i][j]

    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
import numpy as np

def main():
    input = sys.stdin.readline
    N = int(input())
    A = np.array([list(map(int, input().split())) for i in range(N)])
    #A = [list(map(int, input().split())) for _ in range(N)]
    #A = np.array(A)

    INF = 10**10
    for i in range(N):
        A[i][i] = INF

    ans = 0
    for i in range(N):
        for j in range(i):
            #bipas = min(map(sum, zip(A[i], A[j])))
            bipas = np.min(A[i] + A[j])

            if A[i][j] > bipas:
                print(-1)
                return 0
            elif A[i][j] < bipas:
                ans += A[i][j]

    print(ans)


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

K, S = map(int, input().split())

count = 0

for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            if x + y + z == S:
                count += 1

print(count)


### FIXED CODE ###

K, S = map(int, input().split())

count = 0

for x in range(K+1):
    for y in range(K+1):
        z = S - x - y
        if 0 <= z and z <= K:
            count += 1

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

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

ans = 1
for i in A:
    ans *= i

print(-1 if ans > 10 ** 18 else ans)


### FIXED CODE ###

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

if 0 in A:
    print(0)
    exit()

ans = 1
for i in A:
    ans *= i
    
    if ans > 10 ** 18:
        print(-1)
        exit()

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

# Typical Stairs
import sys
input = sys.stdin.readline
import numpy as np

def main():
    n, m = map(int, input().split())
    a = []
    a_ = a.append
    MOD = 10**9 + 7
    for i in range(m):
        a_(int(input()))

    if n == 1:
        print(1)
        exit()

    a = np.array(a)

    dp = [0 for _ in range(n+1)]
    dp[0] = 1
    dp = np.array(dp)
    if 1 in a:
        dp[1] = 0
    else:
        dp[1] = 1

    for i in range(2, n + 1):
        if i in a:
            dp[i] = 0
        else:
            dp[i] = (dp[i - 1] + dp[i - 2]) % MOD

    print(dp[-1])

if __name__ == '__main__':
    main()


### FIXED CODE ###

# Typical Stairs
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main():
    n, m, *a = map(int, read().split())
    MOD = 10**9 + 7

    if n == 1:
        print(1)
        exit()

    dp = [0 for _ in range(n+1)]
    dp[0] = 1
    is_broken = [False] * (n+1)
    for i in a:
        is_broken[i] = True
    if 1 in a:
        dp[1] = 0
    else:
        dp[1] = 1

    for i in range(2, n + 1):
        if is_broken[i]:
            continue
        else:
            dp[i] = (dp[i - 1] + dp[i - 2]) % MOD

    print(dp[-1])

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

#import pysnooper
#import os,re,sys,operator,math,heapq,string
#from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement
from sys import stdin,setrecursionlimit
#from copy import deepcopy

setrecursionlimit(10**6)
input=stdin.readline

n=int(input().rstrip())
print(sum(range(1,n)))

### FIXED CODE ###

#import pysnooper
#import os,re,sys,operator,math,heapq,string
#from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement
from sys import stdin,setrecursionlimit
#from copy import deepcopy

setrecursionlimit(10**6)
input=stdin.readline

n=int(input().rstrip())-1
print((n*(n+1))//2)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
q = int(input())
for i in range(q):
    b, c = map(int, input().split())
    for j in range(len(a)):
        if a[j] == b:
            a[j] = c
    print(sum(a))

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
q = int(input())
nums = [0] * (10 ** 5 + 1)
for i in a:
    nums[i] += 1
nsum = sum(a)
for _ in range(q):
    b, c = map(int, map(int, input().split()))
    nsum = nsum + (c - b) * nums[b]
    print(nsum)
    nums[c] += nums[b]
    nums[b] = 0
### BUGGY CODE ###

n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
d=[]
for i in range(m):
  b,c = map(int,input().split()) 
  d.extend([c]*b)
if n < len(d):
  d=d[:n]
d.sort(reverse=True)
for i in range(len(d)):
  for j in range(n):
    if a[j] < d[i]:
      a[j]=d[i]
      break
print(sum(a))

### FIXED CODE ###

n,m=map(int,input().split())
a=list(map(int,input().split()))
bc=[list(map(int,input().split())) for i in range(m)]
bc.sort(key=lambda x:x[1])
for b,c in bc[::-1]:
  a.extend([c]*b)
  if len(a)>2*n:
    break
a.sort(reverse=True)
print(sum(a[:n]))
### BUGGY CODE ###

def cnt(n, x):
	if x==0:
		return 0
	elif n==0:
		return 1
	elif x<2**(n+1)-1:
		return cnt(n-1, x-1)
	elif 2**(n+1)-1<=x and x<2**(n+2)-3:
		return cnt(n-1, 2**(n+1)-3) + 1 + cnt(n-1, x-2**(n+1)+1)
	else:
		return cnt(n-1, 2**(n+1)-3) + 1 + cnt(n-1, x-2**(n+1))

n, x = map(int, input().split())
print(cnt(n, x))

### FIXED CODE ###

def cnt(n, x):
	if x==0:
		return 0
	elif n==0:
		return 1
	elif x<2**(n+1)-1:
		return cnt(n-1, x-1)
	elif x==2**(n+1)-1:
		return 2**n
	elif x<2**(n+2)-3:
		return cnt(n-1, 2**(n+1)-3) + 1 + cnt(n-1, x-2**(n+1)+1)
	else:
		return 2**(n+1)-1

n, x = map(int, input().split())
print(cnt(n, x))
### BUGGY CODE ###

from collections import deque
import sys
input = sys.stdin.readline
h, w = map(int, input().split())
grid = []
graph = [[2000 for i in range(w)] for j in range(h)]
#x,y渡すと、（ｈ、ｗ）に入ってるかどうか判定
def check(s,t):
    if (0 <=  s <= h - 1) and (0 <= t <= w - 1):
        return True
    else:
        return False

#graph => そこまでの距離を保存した二次元配列　grid=>与えられた迷路
def bfs(que):
    finished = set()
    while que:
        x , y, cost = que.popleft()
        if y*w+x not in finished and graph[y][x] > cost:
            finished.add(y*w+x)
            graph[y][x] = cost
            if check(y,x+1):
                que.append([x+1,y,cost+1])
            if check(y+1,x):
                que.append([x, y+1, cost+1])
            if check(y,x-1):
                que.append([x-1,y,cost+1])
            if check(y-1,x):
                que.append([x,y-1,cost+1])
for i in range(h):
    grid.append(list(input()))
que = deque()
for i in range(h):
    for j in range(w):
        if grid[i][j] == "#":
            que.append((j,i,0))
bfs(que)
ans = 0
for i in range(h):
    ans = max(ans, max(graph[i]))
print(ans)

### FIXED CODE ###

from collections import deque
import sys
input = sys.stdin.readline
h, w = map(int, input().split())
grid = []
graph = [[2000 for i in range(w)] for j in range(h)]
#x,y渡すと、（ｈ、ｗ）に入ってるかどうか判定
def check(s,t):
    if (0 <=  s <= h - 1) and (0 <= t <= w - 1):
        return True
    else:
        return False

#graph => そこまでの距離を保存した二次元配列　grid=>与えられた迷路
def bfs(que):
    finished = set()
    while que:
        x ,y = que.popleft()
        if y*w+x not in finished:
            finished.add(y*w+x)
            for n_x,n_y in [(x+1,y),(x,y+1),(x-1,y),(x,y-1)]:
                if check(n_y,n_x) and graph[n_y][n_x] > graph[y][x] + 1:
                    graph[n_y][n_x] = graph[y][x] + 1
                    que.append((n_x,n_y))
for i in range(h):
    grid.append(list(input()))
que = deque()
for i in range(h):
    for j in range(w):
        if grid[i][j] == "#":
            graph[i][j] = 0
            que.append((j,i))
bfs(que)
ans = 0
for i in range(h):
    ans = max(ans, max(graph[i]))
print(ans)
### BUGGY CODE ###

h, w, d = map(int, raw_input().split())
a = [map(int, raw_input().split()) for _ in xrange(h)]
b = {a[x][y]: (x, y) for x in xrange(h) for y in xrange(w)}
for _ in xrange(input()):
    print sum([sum([abs(b[p][i] - b[p + d][i]) for i in [0, 1]])
               for p in xrange(*(map(int, raw_input().split()) + [d]))])


### FIXED CODE ###

h, w, d = map(int, raw_input().split())
a = [map(int, raw_input().split()) for _ in xrange(h)]
r = {a[x][y]: (x, y) for x in xrange(h) for y in xrange(w)}
b = [0] * (h * w + 1)
for _ in xrange(d + 1, h * w + 1):
    b[_] = b[_ - d] + sum([abs(r[_ - d][i] - r[_][i]) for i in [0, 1]])
for _ in xrange(input()):
    l, r = map(int, raw_input().split())
    print b[r] - b[l]
### BUGGY CODE ###

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

prev = 1
for i in range(K):
    prev *= A[i]

idx = 0
for i in range(K, N):
    if prev < prev // A[idx] * A[i]:
        ans = "Yes"
    else:
        ans = "No"
    print(ans)

    prev = prev // A[idx] * A[i]
    idx += 1

### FIXED CODE ###

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

idx = 0
for i in range(K, N):
    if A[idx] < A[i]:
        ans = "Yes"
    else:
        ans = "No"
    print(ans)

    idx += 1
### BUGGY CODE ###

import heapq
import sys

input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    heapq.heapify(A)
    for i in range(M):
        B, C = map(int, input().split())
        for j in range(B):
            s = min(A)
            if s < C:
                heapq.heappushpop(A, C)
            else:
                break
    ans = sum(A)
    print(ans)

if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys

input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    BC = []
    for _ in range(M):
        BC.append(tuple(map(int, input().split())))
    BC.sort(key=lambda x: x[1])
    vs = []; jtmp = 0
    for i in range(M):
        tmp = BC.pop()
        jtmp += tmp[0]
        if jtmp > N:
            vs.extend([tmp[1]]*(N-(jtmp-tmp[0])))
            break
        else:
            vs.extend([tmp[1]]*tmp[0])
    
    A.sort(reverse=True)
    vs.sort()
    ans = 0
    for _ in range(N):
        tmpA = A.pop()
        if len(vs) > 0:
            tmpC = vs.pop()
        else:
            tmpC = 0
        ans += tmpA*(tmpA>=tmpC) + tmpC*(tmpA<tmpC)
    print(ans)

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

S=input()

N=len(S)
count=0

for i in range(N-3):
    for j in range(i+4,N+1):
        #print(S[i:j])
        if int(S[i:j])%2019==0:
            count+=1
print(count)

### FIXED CODE ###

S=input()

N=len(S)
count=0
tot=[0]*2019
S=S[::-1]
base=0
#print(S)
for i,s in enumerate(S):
    base+=int(s)*pow(10,i,2019)
    base%=2019
    #tot[base]+=1
    #print(base)
    if base==0:
        count+=1
    count+=tot[base]
    #print(tot[base],i,base)
    tot[base]+=1
#print(tot)    

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

from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))

# 素因数分解、リストで返す
#############################################################


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    a.sort()
    return a
#############################################################


primes = defaultdict(int)

for i in range(N):
    p = prime_factorize(A[i])
    p_set = set(p)
    for pi in p_set:
        primes[pi] += 1

# print(primes)

if len(primes) == 0:
    print("pairwise coprime")
    exit()

max_cnt = max(primes.values())
min_cnt = min(primes.values())

if max_cnt == 1:
    print("pairwise coprime")
elif max_cnt != N:
    print("setwise coprime")
else:
    print("not coprime")


### FIXED CODE ###

from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))

# 素因数分解、リストで返す
#############################################################


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    a.sort()
    return a
#############################################################


primes = defaultdict(int)

for i in range(N):
    p = prime_factorize(A[i])
    p_set = set(p)
    for pi in p_set:
        primes[pi] += 1

# print(primes)

if len(primes) == 0:
    print("pairwise coprime")
    exit()

max_cnt = max(primes.values())
min_cnt = min(primes.values())

if max_cnt == 1:
    print("pairwise coprime")
elif max_cnt != N:
    print("setwise coprime")
else:
    print("not coprime")
### BUGGY CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

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()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
ab = [LIST() for _ in range(M)]

ab.sort(key=lambda x:x[1])
# print(ab)

tmp = ab[0][1]
count = 1
for i in range(M):
	a, b = ab.pop(0)
	# print(a, b)
	if a < tmp:
		continue
	else:
		tmp = b
		count += 1
print(count)


### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

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()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
ab = [LIST() for _ in range(M)]

ab.sort(key=lambda x:x[1])
# print(ab)

tmp = ab[0][1]
count = 1
for i in range(M):
	a, b = ab.pop(0)
	# print(a, b)
	if a < tmp:
		continue
	else:
		tmp = b
		count += 1
print(count)
### BUGGY CODE ###

#21 D - Banned K
import collections
from collections import deque
N = int(input())
A = list(map(int,input().split()))
 
cnt = collections.Counter(A)

ans = deque([])
for i in A:
    cnt_cpy = cnt.copy()
    cnt_cpy[i] -= 1
    comb = 0
    for j in cnt_cpy.values():
        if j >= 2:
            comb += (j*(j-1))//2
    ans.append(comb)
for k in ans:
    print(k)

### FIXED CODE ###

#21 D - Banned K AC TLE(hint)
import collections
N = int(input())
A = list(map(int,input().split()))

cnt = collections.Counter(A)
#先に組み合わせの個数を計算しておく
combinations = {}
for j in cnt.keys():
    if cnt[j] >= 2:
        comb = (cnt[j]*(cnt[j]-1))//2
        combinations[j] = comb      

#あるボールを選ばないとき、組み合わせの総数は
#(全組み合わせ数) - (選ばないボールと同じボールの数 - 1)
tot = sum(combinations.values())
ans = []
for i in A:
    a = tot - (cnt[i] - 1)
    ans.append(a)
    
for k in ans:
    print(k)
### BUGGY CODE ###

from itertools import accumulate

n, k = map(int, input().split())
*a, = map(int, input().split())

acc = (0,) + tuple(accumulate(a))

bs = tuple(set() for _ in range(40))

m = 0
for l in range(n):
    for r in range(l + 1, n + 1):
        beauty = acc[r] - acc[l]
        for j in range(40):
            if beauty & (1 << j) > 0:
                bs[j].add(m)
        m += 1

ret = 0
t = set(range(m))
for j in range(39, -1, -1):
    s = t & bs[j]
    if len(s) >= k:
        ret += 1 << j
        t = s
print(ret)


### FIXED CODE ###

from math import log, ceil

n, k = map(int, input().split())
a = tuple(map(int, input().split()))

A_MAX = 10 ** 9
MAX_BIT_LENGTH = ceil(log(A_MAX * n, 2))

cs = [0]
t = 0
for aa in a:
    t += aa
    cs.append(t)

ps = []
for r in range(1, n + 1):
    for l in range(r):
        ps.append(cs[r] - cs[l])

ans = 0
for b in range(MAX_BIT_LENGTH)[::-1]:
    cnt = 0
    t = ans + (1 << b)
    for p in ps:
        if p & t == t:
            cnt += 1
            if cnt == k:
                ans = t
                break

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

n = int(input())
a = [int(x) for x in input().split()]
mult = 1
for i in range(n):
    mult *= a[i]
    if mult == 0:
        print(0)
        break
if mult > 1e+18:
    print(-1)
elif mult != 0:
    print(mult)


### FIXED CODE ###

N = int(input())
L = list(map(int, input().split()))
ans = 1
 
for n in range(N):
 ans = L[n]*ans
 if ans >= 1000000000000000001: ans = -1
 if ans == -1: break
 
for n in range(N):
 if L[n] == 0: ans = 0
print(ans)
### BUGGY CODE ###

N, M = map(int, input().split())
inf =  10**9
dp = [[inf]*2**N for _ in range(M+1)]
for i in range(M+1):
  dp[i][0] = 0

def main():
  for i in range(M):
    a, b = map(int, input().split())
    C = list(map(int, input().split()))
    c_bit = sum([2**(c-1) for c in C])
    for j in range(2**N):
      if dp[i][j] == inf:
        continue
      else:
        #print(min(dp[i][j|c_bit], dp[i][j] + a))
        dp[i+1][j|c_bit] = min(dp[i][j|c_bit], dp[i][j] + a, dp[i+1][j|c_bit])
        dp[i+1][j] = min(dp[i][j], dp[i+1][j])
  if dp[M][2**N-1] == inf:
    print(-1)
  else: 
    print(int(dp[M][2**N-1]))
  
if __name__ == "__main__":
  main()
        

### FIXED CODE ###

N, M = map(int, input().split())
inf =  10**9
dp = [[inf]*2**N for _ in range(M+1)]
for i in range(M+1):
  dp[i][0] = 0

def main():
  for i in range(M):
    a, b = map(int, input().split())
    C = list(map(int, input().split()))
    c_bit = sum([2**(c-1) for c in C])
    for j in range(2**N):
      if dp[i][j] == inf:
        continue
      else:
        #print(min(dp[i][j|c_bit], dp[i][j] + a))
        dp[i+1][j|c_bit] = min(dp[i][j|c_bit], dp[i][j] + a, dp[i+1][j|c_bit])
        dp[i+1][j] = min(dp[i][j], dp[i+1][j])
  if dp[M][2**N-1] == inf:
    print(-1)
  else: 
    print(int(dp[M][2**N-1]))
  
if __name__ == "__main__":
  main()
### BUGGY CODE ###

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

import itertools

# スペース区切りの整数の入力
N,M = list(map(int, input().split()))
xyz = []
for i in range(N):
    xyz.append(list(map(int, input().split())))

xyz_list = itertools.combinations(xyz, M)

sum_list = []
for v in xyz_list:
    xsum = 0
    ysum = 0
    zsum = 0
    all_sum = 0
    for w in v:
        xsum += w[0]
        ysum += w[1]
        zsum += w[2]

    all_sum = abs(xsum) + abs(ysum) + abs(zsum)
    sum_list.append(all_sum)

print(max(sum_list))


### FIXED CODE ###

# -*- coding: utf-8 -*-
from pprint import pprint
import itertools
N, M = map(int, input().split())
xyzn = [list(map(int, input().split())) for _ in range(N)]

ans = []
ope = [1,-1]
for sx, sy, sz in itertools.product(ope, repeat=3):
    xyzn.sort(key=lambda x:-(sx*x[0]+sy*x[1]+sz*x[2]))
    ans.append(sum([sx*x+sy*y+sz*z for x,y,z in xyzn[:M]]))

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

lis=list(map(int,input().split()))
alist=list([int(input()) for _ in range(lis[1])])
steps=[0]*(lis[0]+2)
steps[1]=1
for i in range(2,lis[0]+2):
    if i-1 not in alist:
        steps[i]=(steps[i-1]+steps[i-2])
ans=steps[-1]%((10**9)+7)
print(ans)


### FIXED CODE ###

lis=list(map(int,input().split()))
alist=[0]*(lis[0]+1)
for i in range(lis[1]):
    a=int(input())
    alist[a]=1
steps=[0]*(lis[0]+2)
steps[1]=1
mod=(10**9)+7
for i in range(2,lis[0]+2):
    if alist[i-1]==0:
        steps[i]=(steps[i-1]+steps[i-2])%mod
ans=steps[-1]
print(ans)
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
result = 1
for a in A:
    result = result * a
    if result > pow(10, 18):
        result = -1
else:
    print(result)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
result = 1
flag = 0
zero_flag = 0
for a in A:
    if a == 0:
        zero_flag = 1
        result = 0
        break
    else:
        result = result * a
        if result > pow(10, 18):
            flag = 1
            result = 0
if flag == 1 and zero_flag != 1:
    print(-1)
else:
    print(result)
### BUGGY CODE ###

x = int(input())

a = 0
while(True):
    a5 = a ** 5
    b = x - a5
    b = int(x ** (1 / 5))
    b5 = b**5
    if a5 - b5 == x:
        break
    if a5 - (b5*-1) == x:
        b *= -1
        break
    b = x + a5
    b5 = b**5
    if a5 - b5 == x:
        a *= -1
        break
    if a5 - (b5*-1) == x:
        a *= -1
        b *= -1
        break
    a += 1
    
print(a, b) 

### FIXED CODE ###

x = int(input())

flg = 'n'
for a in range(-120, 121, 1):
    for b in range(-120, 121, 1):
        if a ** 5 - b ** 5 == x:
            flg = 'y'
            break
    if flg == 'y':
        break
print(a, b)