Harryxun/stf_run huggingface dataset:
N = int(input())  #頂点数
tree = [[] for _ in range(N)]
dic = {}
for i in range(N-1):
    u, v, w = map(int, input().split())
    if u > v:
        u, v = v, u
    tree[u-1].append(v-1)
    tree[v-1].append(u-1)
    dic[(u-1, v-1)] = w

#black:1, white:0, none:-1
ans = [-1]*N
ans[0] = 0
flag = [False]*N

def dfs(i):
    flag[i] = True
    for j in tree[i]:
        if flag[j]:
            continue
        x = i
        y = j
        if x > y:
            x, y = y, x
        if dic[(x, y)] % 2 == 0:
            ans[j] = ans[i]
        else:
            if ans[i] == 0:
                ans[j] = 1
            else:
                ans[j] = 0
        if not(flag[j]):
            dfs(j)
            

dfs(0)

#print(tree)
#print(dic)
#print(flag)
for answer in ans:
    print(answer)

### FIXED CODE ###

N = int(input())  #頂点数
tree = [[] for _ in range(N)]
dic = {}
for i in range(N-1):
    u, v, w = map(int, input().split())
    if u > v:
        u, v = v, u
    tree[u-1].append(v-1)
    tree[v-1].append(u-1)
    dic[(u-1, v-1)] = w

import sys
sys.setrecursionlimit(10 ** 8)

#black:1, white:0, none:-1
ans = [-1]*N
ans[0] = 0
flag = [False]*N

def dfs(i):
    flag[i] = True
    for j in tree[i]:
        if flag[j]:
            continue
        x = min(i, j)
        y = max(i, j)
        if dic[(x, y)] % 2 == 0:
            ans[j] = ans[i]
        else:
            if ans[i] == 0:
                ans[j] = 1
            else:
                ans[j] = 0
        if not(flag[j]):
            dfs(j)
            
dfs(0)

for answer in ans:
    print(answer)
print(A*B)

### FIXED CODE ###

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

print(A*B)
s, t = input(), input()
for i in range(len(s)):
    if t = s[len(t)-i:]+s[i:len(t)-i]:
        print('Yes')
        break
else:
    print('No')

### FIXED CODE ###

s, t = input(), input()
for i in range(len(s)):
    if t == s[len(s)-i:]+s[:len(s)-i]:
        print('Yes')
        break
else:
    print('No')
import statistics

N = int(input())
A = [int(i) for i in input().split()]
B = [(A[i] - (i+1)) for i in range(N)]
b = statistics.median(B)
sum = 0
for i in range(N):
    sum += abs(B[i] - b)
print(int(sum))

### FIXED CODE ###

import statistics

N = int(input())
A = [int(i) for i in input().split()]
B = [(A[i] - (i+1)) for i in range(N)]
b = statistics.median(B)
sum = 0
for i in range(N):
    sum += abs(B[i] - b)
print(int(sum))
N,M=map(int(input()))
if N==M:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

N,M=map(int,input().split())
if N==M:
  print("Yes")
else:
  print("No")
n, a, b = map(int,input().split())

sum = ""
for i in range(10**100):
  blue = "b"*a
  red = "r"*b
  sum = sum + blue + red
  if len(sum) >= n:
    ans = sum[:n].count("b")
    break
    
print(ans)

### FIXED CODE ###

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

ans = a*(n//(a+b))+ min(a,n%(a+b))
print(ans)
import sys

S = input()

Q = int(input())
flag=0
mae = ''
matsu = ''
for i in range(Q):
    r = sys.stdin.readline().strip('\n')
    if r == '1':
        flag = 1- flag
    else:
        ni, f, c = r.split()
        if f=='1':
            if flag == 0:
                mae += c
            else:
                matsu += c
        else:
            if flag == 0:
                matsu += c
            else:
                mae += c
    if flag ==0:
        print(mae[::-1]+S+matsu)
    else:
        print(matsu[::-1]+S+mae)

### FIXED CODE ###

import sys

S = input()

Q = int(input())
flag=0
mae = ''
matsu = ''

for i in range(Q):
    r = sys.stdin.readline().rstrip('\n')
    if r == '1':
        flag = 1 - flag
    else:
        ni, f, c = r.split()
        if f=='1':
            if flag == 0:
                mae += c
            else:
                matsu += c
        else:
            if flag == 0:
                matsu += c
            else:
                mae += c


if flag ==0:
    print(mae[::-1]+S+matsu)
else:
    print(matsu[::-1]+S[::-1]+mae)
a,b　= map(int, input().split())
print(a*b)

### FIXED CODE ###

a,b = map(int, input().split())
print(a*b)
A, B, C, X, Y = map(int, input().split())
ans = 0

while X > 0 or Y > 0:
    if C*2 < A + B:
        if X >= 1 and Y >= 1:
            ans += C*2
            X -= 1
            Y -= 1
        elif X >= 1 and Y == 0:
            ans += A
            X -= 1
        elif Y >= 1 and X == 0:
            ans += B
            Y -= 1
    else:
        if X >= 1 and Y >= 1:
            ans += A
            X -= 1
            ans += B
            Y -= 1
        elif Y == 0:
            X -= 1
            ans += A
        elif X == 0:
            Y -= 1
            ans += B

print(ans)


### FIXED CODE ###

S = input()

ans = 700
for i in S:
    if i == "o":
        ans += 100

print(ans)
b = input()
if b == "A":
  print("T")
elif b == "C":
  print("G")
elif b == "G":
  print("C")
else b == "T":
  print("A")


### FIXED CODE ###

b = input()

if b == "A":
  print("T")
elif b == "C":
  print("G")
elif b == "G":
  print("C")
else:
  print("A")
N,M,C=map(int,(input()).split())
List_B=[int(i) for i in (input()).split()]
t=0
for j in range(1,N+1):
  List_A=[int(k) for k in (input()).split()]
  if sum([x*y for (x,y) in zip(List_A,List_B)])>-C:
    t+=1
print(t)


### FIXED CODE ###

H,W=map(int,(input()).split())
h,w=map(int,(input()).split())
print((H-h)*(W-w))
N,M = map(int,input().split())
XY = [[] for i in range(N)]
for i in range(M):
    x,y = map(int,input().split())
    XY[x-1].append(y-1)
print(XY)

dp = [-1 for i in range(N)]
def search(i):
    if dp[i] != -1:
        return dp[i]
    c = 0
    start = XY[i]
    for s in start:
        c = max(c,search(s)+1)
        
    dp[i] = c
    return dp[i]

a = 0
for i in range(N):
    a = max(a,search(i))
print(a)






### FIXED CODE ###

import sys
sys.setrecursionlimit(10**5+10)
input = sys.stdin.readline

N,M = map(int,input().split())
XY = [[] for m in range(N)]
for l in range(M):
    x,y = map(int,input().split())
    XY[x-1].append(y-1)

dp = [-1 for k in range(N)]
def search(i):
    if dp[i] != -1:
        return dp[i]
    c = 0
    start = XY[i]
    for s in start:
        c = max(c,search(s)+1)
    dp[i] = c
    return dp[i]

a = 0
for i in range(N):
    a = max(a,search(i))
print(a)
date = str(input())
date[3]="8"
print(date)

### FIXED CODE ###

S = input()
print(S.replace("2017/","2018/",1))
a,b = map(int,imput().split())
if (a * b) % 2 = 0:
  print(Even)
else:
  print(Odd)

### FIXED CODE ###

a,b = map(int,input().split())
if (a * b) % 2:
  print('Odd')
else:
  print('Even')
n=int(input())
a=list(map(int,input().split()))
b=sorted(a)
if b.count(0)==n:
    print("Yes")
elif n%3==0:
    if b.count(0)==n//3 and b.count(b[n-1])==n-(n//3):
        print("Yes")
    elif b[0]^b[n//3]^b[n-1]==0 and b.count(b[0])==n//3 and b.count(b[n//3])==n//3 and b.count(b[n-1])==n//3:
        print("Yes")
    else:
        print("No")
else:
    print("No")

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
b=a[1]
for i in range(2,n):
    b = b^(a[i])

if b==a[0]:
    print("Yes")
else:
    print("No")
N, A, B=map(int, input().split())
K=int((N-N%(A+B))/(A+B))
ans=(K*A+min(A,N%(A+B))
print(int(round(ans)))

### FIXED CODE ###

N, A, B=map(int, input().split())
K=int((N-N%(A+B))/(A+B))
ans=(K*A+min(A,N%(A+B)))
print(ans)
import collections

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

div = []
for i in range(N):
    for j in range(N):
        if(i == j):
            continue
        div.append(tuple((X[i][0]-X[j][0], X[i][1]-X[j][1])))
        
c = collections.Counter(div)
c_s = sorted(c.items(), key=lambda x:x[1], reverse=True)

print(N-c_s[0][1])

### FIXED CODE ###

import collections

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

div = []
for i in range(N):
    for j in range(N):
        if(i == j):
            continue
        div.append(tuple((X[i][0]-X[j][0], X[i][1]-X[j][1])))
        
c = collections.Counter(div)
c_s = sorted(c.items(), key=lambda x:x[1], reverse=True)

if(N == 1):
    print(1)
else:
    print(N-c_s[0][1])
n=int(input())
m=int(input())
c=int((n*(n-1))//2)
d=int((m*(m-1))//2)
print(c+d)


### FIXED CODE ###

n,m=map(int,input().split())
print((n*(n-1)+m*(m-1))//2)
l=input()
if(int(l[:2])>0 and int(l[2:])>0 and int(l[:2])<=12 and int(l[2:])<=12):
    print('AMBIGUOUS')
elif(int(l[:2])>0 and int(l[2:])>0 and int(l[:2])<=12 and int(l[2:])>=13):
    print("YYMM")
elif(int(l[:2])>0 and int(l[2:])>0 and int(l[:2>=13]) and int(l[2:])<=12):
    print("MMYY")
else:
    print('NA')

### FIXED CODE ###

s = input()
first = int(s[0:2])
second = int(s[2:4])
if 1 <= first <= 12 and 1 <= second <= 12:
    print('AMBIGUOUS')
elif 1 <= first <= 12:
    print('MMYY')
elif 1 <= second <= 12:
    print('YYMM')
else:
    print('NA')
if __name__ == '__main__':
    hidden_key = input()
    flag_string = input()

    key_length = len(hidden_key)
    flag_length = len(flag_string)

    key_list = list(hidden_key.replace('?', 'a'))

    for i in reversed(range(key_length - flag_length + 1)):
        part_key = hidden_key[i:i + flag_length]
        is_match = True

        for j in range(flag_length):
            if part_key[j] != '?' and part_key[j] != flag_string[j]:
                is_match = False
                break
            
        if is_match:
            for k in range(flag_length):
                key_list[i + k] = flag_string[k]
            print(''.join(key_list))
            break

    if not is_match:
        print('UNRESTORABLE')


### FIXED CODE ###

if __name__ == '__main__':
    hidden_key = input()
    flag_string = input()

    key_length = len(hidden_key)
    flag_length = len(flag_string)

    if key_length < flag_length:
        print('UNRESTORABLE')
        exit()

    key_list = list(hidden_key.replace('?', 'a'))

    for i in reversed(range(key_length - flag_length + 1)):
        part_key = hidden_key[i:i + flag_length]
        is_match = True

        for j in range(flag_length):
            if part_key[j] != '?' and part_key[j] != flag_string[j]:
                is_match = False
                break
            
        if is_match:
            for k in range(flag_length):
                key_list[i + k] = flag_string[k]
            print(''.join(key_list))
            break

    if not is_match:
        print('UNRESTORABLE')
a,b=map(int,input().split())
if b==1:print(0)
elif a==b:print(1)
else:
    if (b-1)%(a-1)>0:print((b-1)//(a-1)+n)
    else:print((b-1)//(a-1))

### FIXED CODE ###

a,b=map(int,input().split())
if b==1:print(0)
elif a==b:print(1)
else:
    if (b-1)%(a-1)>0:print((b-1)//(a-1)+1)
    else:print((b-1)//(a-1))
u = input()
for i in (len(u)-1):
    u[i]="x"
print(u)

### FIXED CODE ###

t=input()
u=list(t)
for i in range(len(u)):
    u[i]="x"
    i+=1
t=''.join(u)
print (t)
import sys

def solve(N, T, A, ls_H):
    dosi = []
    titen = []
    titen1 = []
    ti = 1000000
    for x in ls_H :
        do = T - x * 0.006
        dosi.append(do)
    #print(dosi)
    
    for y in dosi :
        ti = A - y
        titen.append(ti)
    #print(titen)
    
    for z in titen :
        titen1.append(abs(z))
    #print(titen1)
    
    for i in titen1 :
        if ti > i :
            ti = i
    #print(ti)
    return titen1.index(ti) + 1


def readQuestion():
    ws = sys.stdin.readline().strip().split()
    N = int(ws[0])
    ws = sys.stdin.readline().strip().split()
    T = int(ws[0])
    A = int(ws[1])
    ws = sys.stdin.readline().strip().split()
    ls_H = list(map(int, ws))
    return (N, T, A, ls_H)

def main():
    print(solve(*readQuestion()))

# Uncomment before submission
main()

### FIXED CODE ###

import sys
 
def solve(N, T, A, ls_H):
    dosi = []
    titen = []
    titen1 = []
    ti = 10**5//1
    for x in ls_H :
        do = T - x * 0.006
        dosi.append(do)
    #print(dosi)
    
    for y in dosi :
        til = A - y
        titen.append(til)
    #print(titen)
    
    for z in titen :
        titen1.append(abs(z))
    #print(titen1)
    
    for i in titen1 :
        if ti > i :
            ti = i
    #print(ti)
    return titen1.index(ti) + 1
 
def readQuestion():
    ws = sys.stdin.readline().strip().split()
    N = int(ws[0])
    ws = sys.stdin.readline().strip().split()
    T = int(ws[0])
    A = int(ws[1])
    ws = sys.stdin.readline().strip().split()
    ls_H = list(map(int, ws))
    return (N, T, A, ls_H)
 
def main():
    print(solve(*readQuestion()))
 # Uncomment before submission
main()
n=int(input())
k=100000000000000000000000000000000000000000
for i in range(n):
  j=0
  a=int(input())
  while a%2==0:
    a=a/2
    j+=1
  min(j,k)
  
print(k)

### FIXED CODE ###

n=int(input())
k=10000000000000000000000000000000000000000
a=list(map(int,input().split()))
for i in range(n):
  j=0
  while a[i]%2==0:
    a[i]=a[i]/2
    j+=1
  k=min(j,k)
  
print(k)
import copy
import itertools

N, X = map(int, input().split())
xlist = [int(i) for i in input().split()]

def pairwise(iterable):
    "s -> (s0,s1), (s1,s2), (s2, s3), ..."
    a, b = itertools.tee(iterable)
    next(b, None)
    return zip(a, b)
  
def calc_energy(path):
  ret = 0
  k = 0
  for pair in pairwise(path):
    ret += (k + 1) ** 2 * abs(pair[0] - pair[1])
    ret += X
    if pair[1] == 0:
      k = 0
    else:
      k += 1
  return ret

def movepath(cur, last):
  if not last:
    yield calc_energy(cur)
  else:
    if cur[-1] == 0:
      for i in last:
        newlast = copy.copy(last)
        for ret in movepath(cur + [i], newlast):
          yield ret
    else:
      newlast = copy.copy(last)
      newlast.remove(cur[-1])
      for i in [0] + newlast:
       	for ret in movepath(cur + [i], newlast):
          yield ret

print(min(calc_energy(path) for path in movepath([0], xlist)))

### FIXED CODE ###

n, x = map(int, input().split())
children = [int(i) for i in input().split()]
children.sort()
count = 0
for child in children:
  if x < child:
    break
  else:
    x -= child
    count += 1
if count == n and x != 0:
  count -= 1
print(count)
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

n= int(input())
ans = 0
for i in range(1, k+1):
  for j in range(1, k+1):
    for k in range(1, k+1):
      ans += gcd(i, j, k)
print(ans)

### FIXED CODE ###

import math
from functools import reduce
 
def gcd(*numbers):
    return reduce(math.gcd, numbers)

n= int(input())
ans = 0
for i in range(1, n+1):
  for j in range(1, n+1):
    for k in range(1, n+1):
      ans += gcd(i, j, k)
print(ans)
def selectionSort(A, N):
    s = 0
    for i in range(N):
        minj = i
        for j in range(i,N):
            if A[j] < A[minj]:
                minj = j
        A[i], A[minj] = A[minj], A[i]
        s += 1
    t = str(A[0])
    for i in range(1,N):
        t = t + " " + str(A[i])
    print(t)
    print(s)

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

slectionSort(a, n)

### FIXED CODE ###

def selectionSort(A, N):
    s = 0
    for i in range(N):
        minj = i
        for j in range(i,N):
            if A[j] < A[minj]:
                minj = j
        A[i], A[minj] = A[minj], A[i]
        if i != minj:
            s += 1
    t = str(A[0])
    for i in range(1,N):
        t = t + " " + str(A[i])
    print(t)
    print(s)

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

selectionSort(a, n)
a,l=map(int,input().split())
s=0
if l/a==2 or l/a==4:
	print("YES")
else:
	f=a*4
	if f>l:
		while f>l:
			f=f-2
		if f==l:
			print("YES")			
		else:
			print("NO")
	else:
		print("NO") 

### FIXED CODE ###

try:
  a=list(map(int,input().split()))
  for i in range(len(a)):
    if a[i]==0:
      print(i+1)
      break
except:
  pass
s = input()
k = int(input())

l = []
for i in range(len(s)-1):
    for y in range(i+1,len(s)+1):
        if not str(s[i:y]) in l:
            l.append(str(s[i:y]))

l.sort()
if len(s) == 1:
    print(s)
else:
    print(l[k-1])


### FIXED CODE ###

s = list(input())
k = int(input())

l = []
for i in range(len(s)):
    for y in range(k):
#        print(''.join(s[i:i+y+1]))
        if not ''.join(s[i:i+y+1]) in l:
            l.append(''.join(s[i:i+y+1]))

l.sort()
if not l:
    print(s[0])
else:
    print(l[k-1])
x,y=map(int,input().split())
if y = 1:
  print(0)
else:
  print(x-y)

### FIXED CODE ###

x,y=map(int,input().split())
if y == 1:
  print(0)
else:
  print(x-y)
print("Yes" if 7 in list(int(input())) else "No")

### FIXED CODE ###

print("Yes" if "7" in list(input()) else "No")
＃@YottyPG　Qiita
from collections import deque

N,M,K = map(int,input().split())
friend = [list(map(int,input().split())) for _ in range(M)]
block = [list(map(int,input().split())) for _ in range(K)]

f = [set() for _ in range(N+1)]
b = [set() for _ in range(N+1)]

for i,j in friend:
    f[i].add(j)
    f[j].add(i)
for i,j in block:
    b[i].add(j)
    b[j].add(i)

stack=deque()
ans = [0]*(N+1)
visited = [0]*(N+1)

for i in range(1,N+1):
    if visited[i]:
        continue
    link = {i}
    visited[i] = 1 
    stack.append(i)
    while stack:
        n = stack.pop()
        for j in f[n]:
            if visited[j]==0:
                stack.append(j)
                visited[j] = 1
                link.add(j)
    for i in link:
        ans[i] = len(link) - len(link & f[i]) - len(link & b[i]) - 1
print(*ans[1:])

### FIXED CODE ###

class UnionFind():
 def __init__(self,n):
   self.n=n
   self.root=[-1]*(n+1)
   self.rank=[0]*(n+1)
 def FindRoot(self,x):
   if self.root[x]<0:
     return x
   else:
     self.root[x]=self.FindRoot(self.root[x])
     return self.root[x]
 def Unite(self,x,y):
   x=self.FindRoot(x)
   y=self.FindRoot(y)
   if x==y:
     return
   else:
     if self.rank[x]>self.rank[y]:
       self.root[x]+=self.root[y]
       self.root[y]=x
     elif self.rank[x]<=self.rank[y]:
       self.root[y]+=self.root[x]
       self.root[x]=y
       if self.rank[x]==self.rank[y]:
         self.rank[y]+=1
 def isSameGroup(self,x,y):
   return self.FindRoot(x)==self.FindRoot(y)
 def Count(self,x):
   return -self.root[self.FindRoot(x)]
 
n,m,k=map(int,input().split())
t=UnionFind(n+1)
cnt=[0]*(n+1) #各iについて、iと同一の連結成分に属する友達関係の人、ブロック関係の人の数を数える
for _ in range(m):
 a,b=map(int,input().split())
 cnt[a]+=1 #各iについて、iと同一の連結成分に属する友達関係の人の数を数える
 cnt[b]+=1
 t.Unite(a,b)
for _ in range(k):
 a,b=map(int,input().split())
 if t.isSameGroup(a,b)==True:
   cnt[a]+=1 #各iについて、iと同一の連結成分に属するブロック関係の人の数を数える
   cnt[b]+=1
ans=[0]*(n+1)
for i in range(1,n+1):
 ans[i]=(t.Count(i)-1)-cnt[i] #答えは(各iが属する連結成分のサイズ)-1-((iと同一の連結成分に含まれているiと友達関係にある人の数)+(iと同一の連結成分に含まれているiとブロック関係にある人の数)となる
print(*ans[1:])
N=int(input())
b=list(map(int,input().split()))
c=[]
for i in range(N):
	c.append(b[i]**2)
print(((sum(b))**2-sum(c))/2)

### FIXED CODE ###

N=list(map(int,input().split()))
if N[0]-N[1]*2>0:
  print(N[0]-N[1]*2)
else:
  print(0)
x=int(input())
ans=1
for j in range(2,11):
    i=1
    while i**j<=x:
        ans=max(ans,i**j)
        i+=1
print(ans)

### FIXED CODE ###

a,b,c,d=map(int,input().split())
if (abs(a-c) <=d or (abs(a-b)<=d and abs(b-c)<=d)):
  print('Yes')
else:print('No')
# coding: utf-8
# Your code here!
import itertools
import pandas as pd

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

lst = [i+1 for i in range(k)]

prod = itertools.product(lst, repeat=3)

frame = pd.DataFrame(list(prod))

frame['ans'] = frame[0]+frame[1]+frame[2]

s_bool = (frame['ans'] ==s)

ans = s_bool.sum()
print(ans)











### FIXED CODE ###

# coding: utf-8
# Your code here!

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

cnt = 0

for i in range(k+1):
    for j in range(k+1):
        if s-i-j <= k and s-i-j>=0:
            cnt += 1

print(cnt)
ans = [0, 0, 0, 0]
for i in range(3):
	x = list(map(int, input().split()))
	for xi in x:
		ans[xi] += 1
if sorted(ans) == [1, 1, 2, 2]:
	print("YES")
else:
	print("NO")


### FIXED CODE ###

ans = [0, 0, 0, 0]
for i in range(3):
	x = list(map(int, input().split()))
	for xi in x:
		ans[xi - 1] += 1
if sorted(ans) == [1, 1, 2, 2]:
	print("YES")
else:
	print("NO")
import sys
n = int(input())
a = list(map(int,input().split())

dp = [sys.maxsize]*n
dp[0] = 0
for i in range(n):
	for j in (i+1,i+2):
         if j < n:
         	dp[j] = min(dp[j], dp[i]+abs(dp[i]-dp[j]))
print(dp[n-1],end="")

### FIXED CODE ###

import sys

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

dp = [sys.maxsize] * n
dp[0] = 0
for i in range(n):
    for j in (i + 1, i + 2):
        if j < n:
            dp[j] = min(dp[j], dp[i] + abs(a[i] - a[j]))
print(dp[n - 1], end="")
K, X = map(int,input().split())
a = 500 * K
if a > X:
  print("Yes")
 else:
  print("No")
 

### FIXED CODE ###

K, X = map(int,input().split())
a = 500 * K
if a >= X:
  print("Yes")
else:
  print("No")
from itertools import permutations

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

cnt=0
for v in permutations(range(1,N+1), N):
    cnt +=1
    if(p==v):
        a = cnt
    if(q==v):
        b = cnt

print(abs(a-b))

### FIXED CODE ###

import itertools
n = int(input())
p = tuple(((map(int,input().split()))))
q = tuple(((map(int,input().split()))))

num = []
for i in range(1,n+1):
    num.append(i)
ans = []
for i in itertools.permutations(num,n):
    ans.append(i)

print(abs(ans.index(p)-ans.index(q)))
import itertools
import heapq
import sys
import functools
import operator
import numpy as np
input = sys.stdin.readline
#-------------
n,k = map(int,input().split())
a = list(map(int,input().split()))
#-------------
a.sort(reverse = True)
w = 10**9 + 7
ans = 1
if k%2 == 1:
  for i in range(k):
    ans *= a[i]
    print(ans % w)

else:
  if n%2 == 0:
    a_new = [a[2*i]*a[2*i+1] for i in range(n//2)]
    a_new.sort(reverse = True)
    for j in range(k//2):
      ans *= a_new[j]
      print(ans % w)
      
  else:
    a_plus = heapq.nlargest(k, a)
    a_minus = heapq.nsmallest(k, a)
    a_plus.sort(reverse = True)
    a_minus.sort()
    a_plus_new = [a_plus[2*i]*a_plus[2*i+1] for i in range(len(a_plus))]
    a_minus_new = [a_minus[2*i]*a_minus[2*i+1] for i in range(len(a_minus))]
    a_new = a_plus_new + a_minus_new
    a_new.sort(revserse = True)
    for j in range(k//2):
      ans *= a_new[j]
      print(ans % w)

### FIXED CODE ###

import sys
 
n, k = map(int, input().split())
a = [int(x) for x in input().split()]
mod = pow(10, 9)+7
zero = 0
plus = []
minus = []
for i in range(n):
  if a[i] == 0:
    zero += 1
  elif a[i] > 0:
    plus.append(a[i])
  else:
    minus.append(a[i])
 
P, M = len(plus), len(minus)
plus.sort(reverse=True)
minus.sort()
ans = 1
if n == k:
  for i in range(n):
    ans *= a[i]
    ans %= mod
elif P+M < k:
  ans = 0
elif P == 0:
  if zero and k%2:
    ans = 0
  else:
    if k%2:
      minus.reverse()
    for i in range(k):
      ans *= minus[i]
      ans %= mod
else:
  q = 0
  if k%2:
    ans *= plus[0]
    ans %= mod
    q = 1
  judge = []
  for i in range((len(plus)-q)//2):
    judge.append(plus[2*i+q]*plus[2*i+q+1])
  for i in range(len(minus)//2):
    judge.append(minus[2*i]*minus[2*i+1])
  judge.sort(reverse=True)
  for i in range(k//2):
    ans *= (judge[i]%mod)
    ans %= mod
 
print(ans)
x,y = map(int,input().split())
ax = abs(x)
ay = abs(y)
if ax == ay and x != y:
    a = 1
elif x > y and 0 < y:
    a = ax - ay + 2
elif x > y and y = 0:
    a = ax - ay + 1
elif x > y and 0 > y:
    if ay > ax and x >= 0:
        a = ay - ax + 1
    elif ay > ax and x < 0:
        a = ay - ax + 2
    elif ax > ay:
        a = ax - ay + 1
elif y > x and x < 0 and ay > ax:
    a = ay - ax + 1
elif y > x and x < 0 and y > 0 and ax > ay:
    a = ax - ay + 1
else:
    a = y-x
print(a)

### FIXED CODE ###

x,y = map(int,input().split())
ax = abs(x)
ay = abs(y)
if ax == ay and x != y:
    a = 1
elif x > y and 0 < y:
    a = ax - ay + 2
elif x > y and y == 0:
    a = ax - ay + 1
elif x > y and 0 > y:
    if ay > ax and x >= 0:
        a = ay - ax + 1
    elif ay > ax and x < 0:
        a = ay - ax + 2
    elif ax > ay:
        a = ax - ay + 1
elif y > x and x < 0 and ay > ax:
    a = ay - ax + 1
elif y > x and x < 0 and y > 0 and ax > ay:
    a = ax - ay + 1
else:
    a = y-x
print(a)
X = input();
A = input();
 
if X<A:
  print(0);
elif X>=A:
  print(10);

### FIXED CODE ###

x, a = map(int, input().split())
 
if x < a:
    print(0)
else:
    print(10)