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

import sys
input=sys.stdin.readline

s=int(input())

#0<= x,y <=10**9
#s/2

if s<=10**9:
    print(0,0,1,0,0,s)
    exit()

hoge=int(s**0.5)

for i in range(2,hoge):
    ss=i
    #print(ss)
    if s%ss==0 and s//ss<=10**9:
        print(0,0,ss,0,0,s//ss)
        exit()



### FIXED CODE ###

import sys
input=sys.stdin.readline

s=int(input())

#0<= x,y <=10**9
#s/2

if s<=10**9:
    print(0,0,1,0,0,s)
    exit()

y=(-1*s//(10**9))*(-1)
x=10**9*y-s

print(0,0,10**9,1,x,y)
### BUGGY CODE ###

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

CommonDivs =[]
for i in range(1, min(A, B)+1): 
    if A%i==B%i==0: 
        CommonDivs.append(i)
        
#print(CommonDivs)

def primes(nums):
    n = len(nums)
    is_prime = [True] * n
    is_prime[0] = True
    is_prime[1] = True
    for i in range(1, n):
        if not is_prime[i]:
            continue
        for j in range(i+1, n):
            if nums[j] % nums[i] == 0:
                is_prime[j] = False
    return {nums[i]: True for i in range(n) if is_prime[i]}

if len(CommonDivs) == 1:
    print(1)
else:
    print(len(primes(CommonDivs)))

### FIXED CODE ###

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


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors

import math

def is_prime(n):
    if n == 1: return True

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

import fractions
x = fractions.gcd(A, B)
divisors = make_divisors(x)
ans = 0
for d in divisors:
    if is_prime(d):
        ans += 1
print(ans)
### BUGGY CODE ###

N = int(input())
ratio = []
for i in range(N):
  ratio.append([int(j) for j in input().split(" ")])
               
vote = ratio[0]

for i in range(len(ratio)-1):
  if ratio[i+1][0] >= vote[0] and ratio[i+1][1] >= vote[1]:
    vote = ratio[i+1]
  
  else:
    a0 = 0
    b0 = 0
    if ratio[i+1][0] < vote[0]:
      seed = ratio[i+1][0]
      base = ratio[i+1][0]
      while(True):
        seed += base
        
        if seed >= vote[0]:
          break
      a0 = seed
      a1 = int(seed * ratio[i+1][1]/ratio[i+1][0])
      la = [a0,a1] 
    
    if ratio[i+1][1] < vote[1]:
      seed = ratio[i+1][1]
      base = ratio[i+1][1]
      while(True):
        seed += base
        if seed >= vote[1]:
          break
      b1 = seed
      b0 = int(seed * ratio[i+1][0]/ratio[i+1][1])
      lb = [b0,b1]
    if a0 > b0:
      vote = [la[0],la[1]]
    else:
      vote = [lb[0],lb[1]]
    
print(sum(vote))

### FIXED CODE ###

N = int(input())
ratio = []
for i in range(N):
  ratio.append([int(j) for j in input().split(" ")])
               
vote = ratio[0]

for i in range(len(ratio)-1):
  if ratio[i+1][0] >= vote[0] and ratio[i+1][1] >= vote[1]:
    vote = ratio[i+1]
  
  else:
    a0 = 0
    b0 = 0
    if ratio[i+1][0] < vote[0]:
      seed = ratio[i+1][0]
      mul = vote[0]//ratio[i+1][0]
      if vote[0]%ratio[i+1][0] != 0:
        mul += 1
      seed *= mul
      a0 = seed
      a1 = mul * ratio[i+1][1]
      la = [a0,a1] 
    
    if ratio[i+1][1] < vote[1]:
      seed = ratio[i+1][1]
      base = ratio[i+1][1]
      
      mul = vote[1]//ratio[i+1][1]
      if vote[1]%ratio[i+1][1] != 0:
        mul += 1
      seed *= mul
      b1 = seed
      b0 = mul * ratio[i+1][0]
      lb = [b0,b1]
    if a0 > b0:
      vote = [la[0],la[1]]
    else:
      vote = [lb[0],lb[1]]
print(sum(vote))
### BUGGY CODE ###

N = int(input())
l = []
c = 0
for i in range(N):
  s = input()
  if s in l:
    continue
  c+=1
  l.append(s)
print(c)

### FIXED CODE ###

N = int(input())
l = []
c = 0
for i in range(N):
  s = input()
  l.append(s)

a = set(l)
print(len(a))
### BUGGY CODE ###

import sys
sys.setrecursionlimit(2147483647)
input=sys.stdin.readline

def main():
  n = int(input())
  a = list(map(int, input().split(' ')))
  a.sort()
  a_max = a[-1]
  db = [0] * a_max
  for i in a:
    if a.count(i) == 1:
      db[i-1] = 1
  for i in a:
    t = 2
    while(i * t <= a_max):
      db[i*t-1] = 0
      t += 1
  print(sum(db))
  

if __name__=='__main__':
  main()

### FIXED CODE ###

import sys
sys.setrecursionlimit(2147483647)
input=sys.stdin.readline

def main():
  n = int(input())
  a = list(map(int, input().split(' ')))
  a.sort()
  a_max = a[-1]
  b = 0
  db = [0] * a_max
  for i in range(1, n-1):
    if a[i] != a[i+1] and a[i] != a[i-1]:
      db[a[i]-1] = 1
  if n == 1 or a[0] != a[1]:
    db[a[0]-1] = 1
  if n > 1 and a[-1] != a[-2]:
    db[-1] = 1
  for i in a:
    t = 2
    while(i * t <= a_max):
      db[i*t-1] = 0
      t += 1
  print(sum(db))
  

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

N = int(input())
S = input()

ans = 99999999

for i in range(N):
    cnt_w = 0
    cnt_e = 0
    for j in range(i):
        if S[j] == 'W':
            cnt_w += 1
    for j in range(i,N):
        if S[j] == 'E':
            cnt_e += 1
    ans = min(ans, cnt_w + cnt_e)
print(ans)

### FIXED CODE ###

N = int(input())
S = input()

ans = 99999999

cnt_w = 0
cnt_e = 0
i = 0
for j in range(i):
    if S[j] == 'W':
        cnt_w += 1
for j in range(i,N):
    if S[j] == 'E':
        cnt_e += 1
ans = cnt_w + cnt_e

for i in range(N):
    if S[i] == 'W':
        cnt_w += 1
    else:
        cnt_e -= 1
    ans = min(cnt_w + cnt_e, ans)
print(ans)
### BUGGY CODE ###

N = int(input())
A = [None] * N
for i in range(N):
    A[i] = int(input())

b = max(A)

for i in range(N):
    if A[i] == b:
        a = A[i]
        A[i] = 0
        ans = max(A)
        print(ans)
        A[i] = a
    else:
        print(b)

### FIXED CODE ###

N = int(input())
A = [None] * N
for i in range(N):
    A[i] = int(input())

l = sorted(A)
b = l[-1]
c = l[-2]

for i in range(N):
    if A[i] == b:
        print(c)
    else:
        print(b)
### BUGGY CODE ###

N = int(input())

if N == 1:
  print(1 if int(input()) != 1 else 0)
  exit()

a = [int(x) for x in input().split()]
 
b = list(set(a))

c = []
for i in b:
  if a.count(i)-i < 0:
    c.append(a.count(i))
  else:
    c.append(a.count(i)-i)

print(sum(c))  
  


### FIXED CODE ###

import collections

N = int(input())

if N == 1:
  print(1 if int(input()) != 1 else 0)
  exit()

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

b = list(collections.Counter(a).items())

c = 0
for i in b:
  if i[1] - i[0] < 0:
    c += i[1]
  else:
    c += i[1] - i[0]

print(c)
### BUGGY CODE ###

N = int(input())
L = list(map(int,input().split()))
L = sorted(L)
L.reverse()
ans = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
         
            
            if L[i] >= L[j] + L[k]:
                break
            ans+=1
print(ans)

### FIXED CODE ###

import bisect
N = int(input())
ans = 0
L = list(map(int,input().split()))
L = sorted(L)
for i in range(N-1):
    for j in range(i+1,N):
        a = bisect.bisect(L,L[i]+L[j]-1)
       
        ans += a-j-1

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

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

ans = n
for i in range(n):
  b = A[i]
  j = i+1
  while j<n:
    if b & A[j] == 0:    
      b += A[j]
      ans += 1
      j += 1
    else:
      break
      
print(ans)      

### FIXED CODE ###

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

ans = 0
l = 0
r = 0
bit = A[0]
total = A[0]

while True:  
  if bit == total:
    ans += r-l+1
    r += 1
    if r == n:
      break
    total += A[r]
    bit ^= A[r]
  else:
    total -= A[l]
    bit ^= A[l]
    l += 1
      
print(ans)
### BUGGY CODE ###

n,a,b=map(int, input().split())
s=list(input())
num=0
qual=[]
s_b=[i for i,x in enumerate(s) if x=='b']
for i in range(n):
  if num<a+b:
    if s[i]=='c':
      qual.append('No')
    elif s[i]=='a':
      num+=1
      qual.append('Yes')     
    else:
      if s_b.index(i)<b:
        num+=1
        qual.append('Yes')
      else:
        qual.append('No')   
  else:
    qual.append('No')
for j in range(n):
  print(qual[j])

### FIXED CODE ###

n,a,b=map(int, input().split())
s=list(input())
num=0
num_f=0
qual=[]
for i in range(n):
  if num<a+b:
    if s[i]=='a':
      num+=1
      qual.append('Yes')     
    elif s[i]=='b' and num_f<b:
      num+=1
      num_f+=1
      qual.append('Yes')
    else:
      qual.append('No')   
  else:
    qual.append('No')
for i in range(n):
  print(qual[i])
### BUGGY CODE ###

N, W = map(int, input().split())
WV = [list(map(int, input().split())) for _ in range(N)]

from collections import Counter

dp = Counter()
dp[0] = 0
for w, v in WV:
  ndp = Counter()
  for k in dp:
   	ndp[k] = max(dp[k], ndp[k])
   	if k+w <= W:
   	 	ndp[k+w] = max(dp[k] + v, ndp[k+w])
  dp = ndp
print(dp.most_common()[0][1])

### FIXED CODE ###

N, W = map(int, input().split())
WV = [list(map(int, input().split())) for _ in range(N)]

from collections import defaultdict

dp = defaultdict(lambda : 10**100)
dp[0] = 0
for w, v in WV:
  ndp = defaultdict(lambda : 10**100)
  for k in dp:
    ndp[k] = min(dp[k], ndp[k])
    if dp[k] + w <= W:
   	  ndp[k+v] = min(dp[k] + w, ndp[k+v])
  dp = ndp
print(max(dp.keys()))
### BUGGY CODE ###

N = int(input())
S = input()

R = []
G = []
B = []
ans = 0

for i, x in enumerate(S):
  if x == 'R':
    R.append(i)
  elif x == 'G':
    G.append(i)
  else:
    B.append(i)

def calc(a, b, c):
  lis = sorted([a, b, c])
  if lis[1] * 2 != lis[0] + lis[2]:
    return 1
  else:
    return 0
        
lis = [calc(r, g, b) for r in R for g in G for b in B]
print(sum(lis))

### FIXED CODE ###

n = int(input())
s = input()
 
r_cnt = s.count('R')
g_cnt = s.count('G')
b_cnt = s.count('B')
 
ans = r_cnt * g_cnt * b_cnt
 
for i in range(n):
    for d in range(n):
        j = i + d
        k = j + d
        if k >= n:break
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            ans -= 1
 
print(ans)
### BUGGY CODE ###

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

ans=0

for i in range(n+1):
  c=int(a*i/b)-a*int(i/b)
  if c>ans:
    ans=c
    
print(ans)

### FIXED CODE ###

A, B, N = map(int, input().split())
 
def solve(i):
  return A * i // B - A * (i // B)
 
print(solve(min(B-1, N)))
### BUGGY CODE ###

import numpy as np
import sys
input = sys.stdin.readline
N,M,Q = map(int,input().split())
LR = []
matrix = np.zeros((N,N)).astype('int')
for i in range(M):
    l,r = map(int,input().split())
    matrix[l-1][r-1] += 1
cumsums = []
for i in range(N):
    c = [0]
    for e in matrix[i]:
        c.append(c[-1]+e)
    cumsums.append(c)
for i in range(Q):
    p,q = map(int,input().split())
    p,q = p-1,q-1
    ans = 0
    for j in range(p,q+1):
        ans += cumsums[j][q+1]-cumsums[j][p]
    print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline
N,M,Q = map(int,input().split())
LR = []
matrix = [[0 for i in range(N+1)] for j in range(N+1)]
for i in range(M):
    l,r = map(int,input().split())
    matrix[l][r] += 1
for i in range(N+1):
    for j in range(N):
        matrix[i][j+1] += matrix[i][j]
for i in range(N+1):
    for j in range(N):
        matrix[j+1][i] += matrix[j][i]
for i in range(Q):
    p,q = map(int,input().split())
    ans = matrix[q][q]-matrix[q][p-1]-matrix[p-1][q]+matrix[p-1][p-1]
    print(ans)
### BUGGY CODE ###

s = input()

cnt = 0
temp = 0

while True:
    cnt += s.count("01") * 2
    s = s.replace("01","")
    
    cnt += s.count("10") * 2
    s = s.replace("10","")
    
    if temp == cnt:
        break
    temp = cnt
    
print(cnt)

### FIXED CODE ###

s = input()

c0 = s.count("0")
c1 = s.count("1")

print(min(c0,c1)*2)
### BUGGY CODE ###

import numpy as np
b = list(map(int, input().split()))
a = list(map(int, input().split()))

p = [i for i in a if i > 0]
m = [i for i in a if i <= 0]
p = np.append(np.diff(np.append([0],p)),[10**10])
m = np.abs(np.append([10**10],np.diff(np.append(m,[0]))))

lp = [0]
lm = [0]

for i in range(b[1]):
    if p[0] > m[-1]:
        lm = lm + m[-1]
        m = np.delete(m, -1)
    else:
        lp = lp + p[0]
        p = np.delete(p, 0)

res = int(lp + lm + min(lm,lp))

print(res)

### FIXED CODE ###

import numpy as np
b = list(map(int, input().split()))
a = list(map(int, input().split()))
x = b[0]-b[1]+1
res = 10**100
 
for i in range(x):
    tmp = i + b[1] - 1
    res = min( a[tmp]-a[i] + min(abs(a[i]),abs(a[tmp])),res)
        
print(res)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
from itertools import accumulate

def merge(i, j):
  if dp1[i] >= A[j]:
    dp2[i] = max(dp2[i], A[j])
  else:
    dp2[i] = dp1[i]
    dp1[i] = A[j]
n = int(input())
A = tuple(map(int, input().split()))
dp1 = [0]*(1<<n)
dp2 = [0]*(1<<n)
for i in range(1<<n):
  j = i
  while j>0:
    merge(i, j)
    j = (j-1)&i
  merge(i, 0)
L = list(accumulate([a+b for a, b in zip(dp1, dp2)], max))
print(*L[1:], sep="\n")

### FIXED CODE ###

import sys
input = sys.stdin.readline
from itertools import accumulate

def merge(x, y):
  D = sorted([dp[x][0], dp[x][1], dp[y][0], dp[y][1]], reverse=True)
  return (D[0], D[1])
  
n = int(input())
A = tuple(map(int, input().split()))
dp = [(a, 0) for a in A]
for j in range(n):
  for i in range(1<<n):
    if i & (1<<j):
      dp[i] = merge(i, i & ~(1<<j))
L = tuple(accumulate((sum(d) for d in dp), max))
print(*L[1:], sep="\n")
### BUGGY CODE ###

N = int(input())
S = [s for s in input()]
lis = [str(i)+str(j)+str(k) for i in range(10) for j in range(10) for k in range(10)]
ans = 0
for s in lis:
    flag = 0
    for i in range(N-2):
        if flag:break
        if S[i] == s[0]:
            for j in range(i+1,N-1):
                if S[j] == s[1]:
                    if s[2] in set(S[j+1:]):
                        ans += 1
                        flag = 1
                        break
print(ans)

### FIXED CODE ###

N = int(input())
S = [s for s in input()]
lis = [str(i)+str(j)+str(k) for i in range(10) for j in range(10) for k in range(10)]
ans = 0
from collections import defaultdict
d = defaultdict(list)
for i,s in enumerate(S):
    d[s].append(i)

for s in lis:
    if d[s[0]]:
        i = min(d[s[0]])
        if d[s[1]]:
            for j in d[s[1]]:
                if j > i:
                    if d[s[2]]:
                        if max(d[s[2]]) > j:
                            ans += 1
                            break
                    break
        else:continue
    else:continue
                            
print(ans)
### BUGGY CODE ###

from heapq import heappush, heappop

N, M = map(int, input().split())
q = list()
for _ in range(N):
    A, B = map(int, input().split())
    deadline = M - A
    reward_inv = -B
    if deadline >= 0:
        heappush(q, (reward_inv, deadline))

ans = [0] * (M + 1)
while len(q) > 0:
    reward_inv, deadline = heappop(q)
    while ans[deadline] != 0 and deadline > 0:
        deadline -= 1
    if ans[deadline] < -reward_inv:
        ans[deadline] = -reward_inv

print(sum(ans))

### FIXED CODE ###

from heapq import heappush, heappop
from collections import defaultdict
N, M = map(int, input().split())
d = defaultdict(list)  # {deadline: [rewards]}
for _ in range(N):
    A, B = map(int, input().split())
    deadline = M - A
    d[deadline].append(B)

ans = list()
for day in range(M + 1):
    rewards = d.get(day)
    if rewards is None or len(rewards) == 0:
        continue
    # rewards.sort(reverse=True)
    for reward in rewards:
        if len(ans) <= day:
            heappush(ans, reward)
        else:
            min_reward = heappop(ans)
            if reward > min_reward:
                heappush(ans, reward)
            else:
                heappush(ans, min_reward)

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

def main():
  import sys
  input=sys.stdin.readline
  h,w,k=map(int,input().split())
  sx,sy,tx,ty=map(int,input().split())
  calc=lambda x,y:x*1000007+y
  b=[[-1]*(w+2)]
  for i in range(h):
    s=input()
    bb=[-1]
    for j in s:
      if j==".":bb.append(0)
      else:bb.append(-1)
    bb.append(-1)
    b.append(bb)
  b.append([-1]*(w+2))
  d=[]
  d.append((sx,sy))
  s=set()
  for ss in d:
    x,y=ss
    if calc(x,y)in s:
      s.discard(calc(x,y))
      continue
    if x==tx and y==ty:
      exit(print(b[x][y]))
    for i in range(1,k+1):
      if b[x-i][y]<=b[x][y] and b[x-i][y]!=0:break
      d.append((x-i,y))
      if b[x-i][y]!=0:
        s.add(calc(x-i,y))
      b[x-i][y]=b[x][y]+1
    for i in range(1,k+1):
      if b[x+i][y]<=b[x][y] and b[x+i][y]!=0:break
      d.append((x+i,y))
      if b[x+i][y]!=0:
        s.add(calc(x+i,y))
      b[x+i][y]=b[x][y]+1
    for j in range(1,k+1):
      if b[x][y-j]<=b[x][y] and b[x][y-j]!=0:break
      d.append((x,y-j))
      if b[x][y-j]!=0:
        s.add(calc(x,y-j))
      b[x][y-j]=b[x][y]+1
    for j in range(1,k+1):
      if b[x][y+j]<=b[x][y] and b[x][y+j]!=0:break
      d.append((x,y+j))
      if b[x][y+j]!=0:
        s.add(calc(x,y+j))
      b[x][y+j]=b[x][y]+1
  print(-1)
if __name__ == "__main__":
  main()


### FIXED CODE ###

import sys
input=sys.stdin.readline
h,w,k=map(int,input().split())
si,sj,ti,tj=map(int,input().split())
si-=1
sj-=1
ti-=1
tj-=1
b=[input()for _ in range(h)]
ans=[[-1]*w for _ in range(h)]
ans[si][sj]=0
from collections import deque
d=deque()
d.append((si,sj))
while d:
  x,y=d.popleft()
  if x==ti and y==tj:
    exit(print(ans[x][y]))
  for dx,dy in [[1,0],[-1,0],[0,-1],[0,1]]:
    for i in range(1,k+1):
      xx=x+dx*i
      yy=y+dy*i
      if not(0<=xx<h and 0<=yy<w) or b[xx][yy]=="@":break
      if 0<=ans[xx][yy]<=ans[x][y]:break
      if ans[xx][yy]==-1:d.append((xx,yy))
      ans[xx][yy]=ans[x][y]+1
print(-1)
### BUGGY CODE ###

from bisect import bisect_left
N = int(input())
L = sorted(list(map(int, input().split())))

ans = 0
for b in range(1, N - 1):
    for a in range(b):
        ans += bisect_left(L[b + 1:], L[a] + L[b])
        
print(ans)

### FIXED CODE ###

from bisect import bisect_left
N = int(input())
L = sorted(list(map(int, input().split())))

ans = 0
for b in range(1, N - 1):
    for a in range(b):
        ans += bisect_left(L, L[a] + L[b]) - b - 1
        
print(ans)
### BUGGY CODE ###

# coding: utf-8

# 標準入力 <int>
N = int(input())

# 標準入力 <int> list[]
P = list(map(int, input().split()))

count = 0

for i in range(N):
    isOK = True
    for j in range(i + 1):
        if P[i] > P[j]:
            isOK = False
            break
    if isOK:
        count += 1

print(count)


### FIXED CODE ###

# coding: utf-8

# 標準入力 <int>
N = int(input())

# 標準入力 <int> list[]
P = list(map(int, input().split()))

count = 0
comp = 2 * (10**5)

for i in range(N):
    if comp >= P[i]:
        count += 1
        comp = P[i]

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

n, m = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for _ in range(m)]
BC.sort(key=lambda x: -x[1])

extend = A.extend
[extend([ls[1]] * ls[0]) for ls in BC]
A.sort(reverse=True)

print(sum(A[:n]))

### FIXED CODE ###

import sys

input = sys.stdin.readline
n, m = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for _ in range(m)]
BC.sort(key=lambda x: -x[1])

maxi = n*2
extend = A.extend
[extend([ls[1]] * ls[0]) for ls in BC if len(A) <= maxi]
A.sort(reverse=True)

print(sum(A[:n]))
### BUGGY CODE ###

import math

N = int(input())
A = N
S = []
for i in range(N):
    S += [input()]
for j in range (1, N):
    for k in range(j):
        if S[k] == S[j]:
            A -= 1
            break
print(A)


### FIXED CODE ###

N = int(input())
S = [input() for _ in range(N)]
print(len(set(S)))
### BUGGY CODE ###

while True:
  r,c = map(int,input().split())
  if not r and not c:
    break
  lst = []
  for i in range(r):
    lst.append(list(map(int,input().split())))
  def dfs(l,n):
    if n == r:
      ans = 0
      for i in range(c):
        count = 0
        for j in range(r):
          if l[j][i]:
            count += 1
        ans += max(count, r - count)
      return ans
    else:
      return max(dfs(l + [[0 if i else 1 for i in lst[n]]],n + 1),
                 dfs(l + [[1 if i else 0 for i in lst[n]]],n + 1))
  print(dfs([],0))



### FIXED CODE ###

def f():
  while True:
    r,c = map(int,input().split())
    if not r:
      break
    lst = [list(map(int,input().split())) for i in range(r)]
    dic = [0 for i in range(2 ** r)]
    for i in range(c):
      num = 0
      for j in range(r):
        num *= 2
        num += lst[j][i]
      dic[num] += 1
    ans = 0
    for i in range(2 ** r):
      ret = 0
      for j in range(2 ** r):
        num = (i ^ j)
        cnt = 0
        for k in range(r):
          cnt += num % 2
          num //= 2
        ret += max(cnt, r - cnt) * dic[j]
      ans = max(ans, ret)
    print(ans)
f()
### BUGGY CODE ###

K = int(input())

if K % 2 == 0:
    print(-1)
else:
    i = 1
    v = 7
    while True:
        if v % K == 0:
            print(i)
            break
        else:
            i += 1
            v = v * 10 + 7
            v %= K

### FIXED CODE ###

K = int(input())

if K % 2 == 0 or K % 5 == 0:
    print(-1)
else:
    i = 1
    v = 7
    while True:
        if v % K == 0:
            print(i)
            break
        else:
            i += 1
            v = v * 10 + 7
            v %= K
### BUGGY CODE ###

N,K,Q = map(int, input().split())
A = []
for a in range(Q):
	A.append(int(input()))
Players_Number = []

for i in range(1,N+1):
    Players_Number.append(i)

for i in Players_Number:
    judge = ((K-Q) + (A.count(i)))
    if judge > 0 :
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

N,K,Q = map(int, input().split())
A = []
for a in range(Q):
	A.append(int(input()))


P = [K-Q] * N
for i in range(Q):
    P[A[i]-1] += 1
for i in range(N):
    if P[i] <= 0:
        print("No")
    else:
        print("Yes")
### BUGGY CODE ###

def solve():
    MOD = 10**9 + 7

    N = int(input())
    Ass = [tuple(map(int, input().split())) for _ in range(N)]

    dp = [0] * (1<<N)
    dp[0] = 1
    for S in range((1<<N)-1):
        dp[S] %= MOD
        iM = bin(S).count('1')
        for iW in range(N):
            if S & (1<<iW) == 0 and Ass[iM][iW]:
                S2 = S ^ (1<<iW)
                dp[S2] += dp[S]

    print(dp[-1] % MOD)


solve()


### FIXED CODE ###

MOD = 10**9 + 7

N = int(input())
As = [int(input().replace(' ', ''), 2) for _ in range(N)]

patWsList = [[] for _ in range(N+1)]
for patW in range(2**N):
    num1 = sum([(patW >> i) & 1 for i in range(N)])
    patWsList[num1].append(patW)

dp = [0] * (2**N)
dp[-1] = 1
for iM, (A, patWs) in enumerate(zip(As, reversed(patWsList))):
    for patW in patWs:
        A2 = A & patW
        dpNow = dp[patW]
        for iW in range(N):
            if A2 & (1 << iW):
                dp[patW ^ (1 << iW)] += dpNow
                dp[patW ^ (1 << iW)] %= MOD

print(dp[0])
### BUGGY CODE ###

# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np


# なんこか入力
n,m = map(int, input().split())

# 空白区切りの数列をリストに代入
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = []

a.sort()
b.sort()
if a[-1] != n*m or b[-1] != n*m:
    print("0")
    exit()
    
t=1
ax = 0
bx = 0

for i in range(n*m,0,-1):

    if i in a and i in b:
        ax += 1
        bx += 1
    elif i in a:
        ax += 1
        t = t * bx % (1000000007)
    elif i in b:
        bx += 1
        t = t * ax % (1000000007)
    else:
        t = t * (ax*bx-n*m+i) % (1000000007)
    
print(t)



### FIXED CODE ###

# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np


# なんこか入力
n,m = map(int, input().split())

# 空白区切りの数列をリストに代入
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = []

a= set(a)
b= set(b)
if len(a) != n or len(b) != m:
    print("0")
    exit()
    
t=1
ax = 0
bx = 0

for i in range(n*m,0,-1):

    if i in a and i in b:
        ax += 1
        bx += 1
    elif i in a:
        ax += 1
        t = t * bx % (1000000007)
    elif i in b:
        bx += 1
        t = t * ax % (1000000007)
    else:
        t = t * (ax*bx-n*m+i) % (1000000007)
    
print(t)