Problem:


Score : 300 points

Problem Statement

Given are positive integers N, M, Q, and Q quadruples of integers ( a_i , b_i , c_i , d_i ).

Consider a sequence A satisfying the following conditions:

A is a sequence of N positive integers.

1 \leq A_1 \leq A_2 \le \cdots \leq A_N \leq M.

Let us define a score of this sequence as follows:

The score is the sum of d_i over all indices i such that A_{b_i} - A_{a_i} = c_i. (If there is no such i, the score is 0.)

Find the maximum possible score of A.

Constraints

All values in input are integers.

2 ≤ N ≤ 10

1 \leq M \leq 10

1 \leq Q \leq 50

1 \leq a_i < b_i \leq N ( i = 1, 2, ..., Q )

0 \leq c_i \leq M - 1 ( i = 1, 2, ..., Q )

(a_i, b_i, c_i) \neq (a_j, b_j, c_j) (where i \neq j)

1 \leq d_i \leq 10^5 ( i = 1, 2, ..., Q )

Input

Input is given from Standard Input in the following format:

N M Q
a_1 b_1 c_1 d_1
:
a_Q b_Q c_Q d_Q

Output

Print the maximum possible score of A.

Sample Input 1

3 4 3
1 3 3 100
1 2 2 10
2 3 2 10

Sample Output 1

110

When A = \{1, 3, 4\}, its score is 110. Under these conditions, no sequence has a score greater than 110, so the answer is 110.

Sample Input 2

4 6 10
2 4 1 86568
1 4 0 90629
2 3 0 90310
3 4 1 29211
3 4 3 78537
3 4 2 8580
1 2 1 96263
1 4 2 2156
1 2 0 94325
1 4 3 94328

Sample Output 2

357500

Sample Input 3

10 10 1
1 10 9 1

Sample Output 3

1



Sample input:
3 4 3
1 3 3 100
1 2 2 10
2 3 2 10


Sample output:
110

Submission status: Wrong Answer

Solution code:
str1 = str(input())
s1 = str1.split(' ')
n =  int(s1[0])
m = int(s1[1])
q = int(s1[2])
l=[]
for i in range(q):
    l2_1=str(input(' ')).split(' ')
    l2 = [int(x) for x in l2_1]
    l.append(l2)
d={}
tbs = []
for i in l:
    test = i[:-1]
    d[i[-1]] = test 
    tbs.append(i[-1])
tbs.sort()
l2=[-100]*10000
sum1 = 0 
for i in tbs:
    temp = d[i]
    if(l2[temp[0]]!=-100 and l2[temp[1]]!=-100):
        if l2[temp[1]]-l2[temp[0]] == temp[2]:
            sum1+=i
    elif (l2[temp[0]]==-100 and l2[temp[1]]!=-100):
        l2[temp[0]]= l2[temp[1]] - temp[2]
        sum1+=i
    elif (l2[temp[0]]!=-100 and l2[temp[1]]==-100):
        l2[temp[1]] = l2[temp[0]]+temp[2]
        sum1+=i
    else:
        l2[temp[0]] = 10
        l2[temp[1]] = 10 + l2[temp[2]]
        sum1+=i 
print(sum1)

Submission status: Wrong Answer

Solution code:
import itertools
n,m,q=map(int,input().split())
abcd=[None]*q
for i in range(q):
    abcd[i]=list(map(int,input().split()))
num=0
for l in list(map(list, itertools.combinations(list(range(1,m+1))*m, n))):
    num_ = 0
    for x in abcd:
        if l[x[1]-1]-l[x[0]-1] == x[2]:
            num_ += x[3]
    num = max(num ,num_)
print(num)

Submission status: Wrong Answer

Solution code:
input = raw_input

from copy import deepcopy

n, m, q = map(int, input().split(" "))

score_dict = {}

for i in range(1, n):
    for j in range(i+1, n+1):
        key = (i, j)
        score_dict[key] = []

all_inputs = []
for i in range(q):
    a, b, c, d = map(int, input().split(" "))
    key = (a, b)
    score_dict[key].append([c, d])
    all_inputs.append([a, b, c, d])

a_list = [set([]) for i in range(n+1)]
a_list[1] = {0}

all_keys = [(i, cur) for cur in range(n+1) for i in range(1, cur)]
used = {}
for key in all_keys:
    pairs = score_dict[key]
    if len(pairs) == 0:
        used[key] = False

    i, j = key
    assert 1 <= i < j
    ais = deepcopy(a_list[i])
    ajs = deepcopy(a_list[j])
    for c, d in pairs:
        for ai in ais:
            aj = ai + c
            a_list[j].add(aj)

        for aj in ajs:
            ai = aj - c
            if ai < 0:
                continue
            a_list[i].add(ai)


#print(a_list)

all_a_kumis = []

def f(last, last_i):
    if last_i == n:
        all_a_kumis.append(last)
        return

    cur_i = last_i+1
    if len(a_list[cur_i]) == 0:
        a_list[cur_i] = a_list[cur_i-1]
    for a in a_list[cur_i]:
        if last[-1] <= a:
            cur = last + [a]
            f(cur, cur_i)
        
f([0], 1)
#print(all_a_kumis)

out = 0
for cur_as in all_a_kumis:
    cur = 0
    for a, b, c, d in all_inputs:
        a -= 1
        b -= 1
        if cur_as[b] - cur_as[a] == c:
            cur += d
    out = max(out, cur)

print(out)



#last_end_ki = -1
#queues = []
#all_keys = [(i, cur) for cur in range(n+1) for i in range(1, cur)]
#
#last_end_ki = -1
#ki_dict = {}
#for cur in range(2, n+1):
#    start_ki = last_end_ki+1
#    end_ki = start_ki+cur-2
#    #cur_keys = all_keys[start_ki:end_ki+1]
#    ki_dict[cur] = [start_ki, end_ki]
#    last_end_ki += (cur-1)

Submission status: Wrong Answer

Solution code:
# import math
# from collections import Counter

# N = int(input()) # 1行, 単数
# arg = list(map(int, input().split())) # 1行, 配列
# D = Counter(arg) # 出現数カウント

# print('Yes')
# print('No')
# print()
arg = list(map(int, input().split())) # 1行, 配列
N = arg[0]
M = arg[1]
Q = arg[2]

listA=[]
maxim = 0

while True:
  try:
    listA.append(list(map(int,input().split())))
  except:
    break;
A = []
As = []

for x in range(1,M+1):
  A = [x] * N
  As.append(list(A))
  for i in list(range(N-1,-1,-1)):
    while A[i] < M:
      A[i] = A[i] + 1
      As.append(list(A))

for item in As:
  letMaxim = 0
  for l in listA:
    if item[l[1]-1] - item[l[0]-1] == l[2]:
      letMaxim = letMaxim + l[3]
  if maxim < letMaxim:
    maxim = letMaxim


print(maxim)

Submission status: Wrong Answer

Solution code:
N, M, Q = (int(i) for i in input().split())  
ABCD = []
ans = -1

for _ in range(Q):
  ABCD.append([int(i) for i in input().split()] )

comb_list = []

import sys
sys.setrecursionlimit(100000000)
def recur(N, lis, c):
  if len(lis) == N:
    comb_list.append(lis)
    return

  if lis == []:
    for i in range(1, N+1):
      recur(N, [i], c+1)
  else:
    for i in range(lis[c], N+1):
      recur(N, lis + [i], c+1)     

recur(N, [], -1)
for x in comb_list:
    tmp = 0
    for a, b, c, d in ABCD:
        if x[b-1] - x[a-1] == c:
             tmp += d
                
    ans = max(ans, tmp)   
print(ans)

Submission status: Wrong Answer

Solution code:
import itertools

n, m, q = map(int, input().split())

nums = []
for _ in range(q):
    nums.append(list(map(int, input().split())))

total = 0

l = [1,2,3,4,5,6,7,8,9,10]
for v in itertools.combinations_with_replacement(l, n):
    scores = []
    for a,b,c,d in nums:
        if v[b-1]-v[a-1] == c:
            scores.append(d)
        else:
            scores.append(0)
    if total < sum(scores):
        total = sum(scores)

print(total)

Submission status: Wrong Answer

Solution code:
n,m,q = (int(num) for num in input().split())
a = [0] * q
b = [0] * q
c = [0] * q
d = [0] * q

for i in range(q):
    at,bt,ct,dt = (int(num) for num in input().split())
    a[i] = at
    b[i] = bt
    c[i] = ct
    d[i] = dt
    
def calc(s,a,b,c,d):
    ret = 0
    for i in range(q):
        if int(s[b[i]-1]) - int(s[a[i]-1]) == c[i]:
            ret += d[i]
    return ret

ans = 0
qu = [str(num) for num in range(m)]
while True:
    s = qu.pop(0)
    if len(s) >= n:
        break
    t = int(s[-1])
    for i in range(t,m):
        qu.append(s + str(i))

for si in qu:
    s = str(si)
    if len(s) < n:
        s = "0" * (n-len(s)) + s
    ans = max(ans, calc(s,a,b,c,d))
    
print(ans)

Submission status: Wrong Answer

Solution code:
N,M,Q=map(int,input().split())
A=[list(map(int,input().split())) for i in range(Q)]
A=sorted(A,key=lambda x:(x[0],x[1]))
ans=0
dic=[1]*N
def make(N,ans):
  def saiki(i,j,_,ans):
    if i==N-1:
      for k in range(j,11):
        _[i]=k
        _ans=0
        for a in A:
          if _[a[1]-1]-_[a[0]-1]==a[2]:
            _ans+=a[3]
        ans=max(ans,_ans)
        #print(_)
      return ans
    for k in range(j,11):
      _[i]=k
      ans=saiki(i+1,k,_,ans)
    return ans

  _=[1]*N
  i=0
  for j in range(1,11):
    ans=saiki(i,j,_,ans)
  return ans
ans=make(N,ans)
print(ans)

Submission status: Wrong Answer

Solution code:
[n, m, q] = [int(x) for x in input().split(' ')]

a = []
b = []
c = []
d = []

for _ in range(q):
  tmp = [int(x) for x in input().split(' ')]
  a.append(tmp[0]-1)
  b.append(tmp[1]-1)
  c.append(tmp[2])
  d.append(tmp[3])

x = [1] * 10

def next(x):
  for i in range(9, -1, -1):
    if x[i] != 10:
      x[i] += 1
      for j in range(i, 10):
        x[j] = x[i]
      return True
  else:
    return False

def score(x):
  s = 0
  for i in range(q):
    if x[b[i]] - x[a[i]] == c[i]:
      s += d[i]
  return s

ans = score(x)
while next(x):
  ans = max(ans, score(x))

print(ans)

Submission status: Wrong Answer

Solution code:
from collections import deque
n,m,q = map(int,input().split())
l = list(list(map(int,input().split())) for _ in range(q))
num = ["1"*n]
k = deque(["1"*n])
while len(k)!=0:
  h = k.popleft()
  if int(h[-1])<m:
    num.append(str(int(h)+1))
    num.append(str(int(h)+11))
    num.append(str(int(h)+111))
    k.append(str(int(h)+1))
    k.append(str(int(h)+11))
    k.append(str(int(h)+111))
num = list(set(num))
ma = 0
for i in num:
  s = 0
  for a,b,c,d in l:
    if int(i[b-1])-int(i[a-1])==c:
      s += d
      ma = max(ma,s)
print(ma)

Submission status: Wrong Answer

Solution code:
import itertools
n, m, q = map(int, input().split())
list_score = [ list(map(int,input().split(" "))) for i in range(q)]
list_NUM = [i for i in range(1, m+1)]
ans = 0

if q < n:
    for l in list_score:
        ans += l[3]
else:
    for l in itertools.product(list_NUM, repeat=n):
        cnt = 0
        for h in list_score:
            if l[h[1]-1] - l[h[0]-1] == h[2]:
                cnt += h[3]

        ans = max(ans, cnt)

print(ans)

Submission status: Wrong Answer

Solution code:

maxscore = 0



def solve():
    ans = [-1]*n
    ans[-1] = m
    rek(ans, m, 1)
    return

def rek(ans, m, rekdepth):
    global maxscore
    curr_ans = ans.copy()
    for i in range(m+1):
        curr_ans[-rekdepth-1] = i
        if rekdepth == n-1:
            score = get_score(curr_ans)
            maxscore = max(maxscore, score)
        else:
            rek(curr_ans.copy(), i, rekdepth + 1)


def get_score(arr):
    score = 0
    for (a, b, c, d) in abcd:
        if (arr[b-1] - arr[a-1] == c):
            score += d
    return score



# n = int(input())
n, m, q = [int(s) for s in input().split(" ")]
abcd = []
for i in range(q):
    abcd.append([int(s) for s in input().split(" ")])

solve()
print(maxscore)

Submission status: Wrong Answer

Solution code:
import math
a, b, n = map(int, input().split())
if b>n:
    print(math.floor(a*n/b))
else:
    y = a-1 if a>b else b-1
    x = y if y>n else n
    print(math.floor(a*x/b)-a*math.floor(x/b))

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys
import math
read = sys.stdin.readline

n , m , q = map(int,input().split())
X = []
[X.append(list(map(int,input().split()))) for _ in range(q)]
# X = sorted(X , key = lambda x:(x[3]) , reverse= True)


A2 = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [6, 7], [6, 8], [6, 9], [6, 10], [7, 8], [7, 9], [7, 10], [8, 9], [8, 10], [9, 10]]
A3 = [[1, 2, 3], [1, 2, 4], [1, 2, 5], [1, 2, 6], [1, 2, 7], [1, 2, 8], [1, 2, 9], [1, 2, 10], [1, 3, 4], [1, 3, 5], [1, 3, 6], [1, 3, 7], [1, 3, 8], [1, 3, 9], [1, 3, 10], [1, 4, 5], [1, 4, 6], [1, 4, 7], [1, 4, 8], [1, 4, 9], [1, 4, 10], [1, 5, 6], [1, 5, 7], [1, 5, 8], [1, 5, 9], [1, 5, 10], [1, 6, 7], [1, 6, 8], [1, 6, 9], [1, 6, 10], [1, 7, 8], [1, 7, 9], [1, 7, 10], [1, 8, 9], [1, 8, 10], [1, 9, 10], [2, 3, 4], [2, 3, 5], [2, 3, 6], [2, 3, 7], [2, 3, 8], [2, 3, 9], [2, 3, 10], [2, 4, 5], [2, 4, 6], [2, 4, 7], [2, 4, 8], [2, 4, 9], [2, 4, 10], [2, 5, 6], [2, 5, 7], [2, 5, 8], [2, 5, 9], [2, 5, 10], [2, 6, 7], [2, 6, 8], [2, 6, 9], [2, 6, 10], [2, 7, 8], [2, 7, 9], [2, 7, 10], [2, 8, 9], [2, 8, 10], [2, 9, 10], [3, 4, 5], [3, 4, 6], [3, 4, 7], [3, 4, 8], [3, 4, 9], [3, 4, 10], [3, 5, 6], [3, 5, 7], [3, 5, 8], [3, 5, 9], [3, 5, 10], [3, 6, 7], [3, 6, 8], [3, 6, 9], [3, 6, 10], [3, 7, 8], [3, 7, 9], [3, 7, 10], [3, 8, 9], [3, 8, 10], [3, 9, 10], [4, 5, 6], [4, 5, 7], [4, 5, 8], [4, 5, 9], [4, 5, 10], [4, 6, 7], [4, 6, 8], [4, 6, 9], [4, 6, 10], [4, 7, 8], [4, 7, 9], [4, 7, 10], [4, 8, 9], [4, 8, 10], [4, 9, 10], [5, 6, 7], [5, 6, 8], [5, 6, 9], [5, 6, 10], [5, 7, 8], [5, 7, 9], [5, 7, 10], [5, 8, 9], [5, 8, 10], [5, 9, 10], [6, 7, 8], [6, 7, 9], [6, 7, 10], [6, 8, 9], [6, 8, 10], [6, 9, 10], [7, 8, 9], [7, 8, 10], [7, 9, 10], [8, 9, 10]]
A4 = [[1, 2, 3, 4], [1, 2, 3, 5], [1, 2, 3, 6], [1, 2, 3, 7], [1, 2, 3, 8], [1, 2, 3, 9], [1, 2, 3, 10], [1, 2, 4, 5], [1, 2, 4, 6], [1, 2, 4, 7], [1, 2, 4, 8], [1, 2, 4, 9], [1, 2, 4, 10], [1, 2, 5, 6], [1, 2, 5, 7], [1, 2, 5, 8], [1, 2, 5, 9], [1, 2, 5, 10], [1, 2, 6, 7], [1, 2, 6, 8], [1, 2, 6, 9], [1, 2, 6, 10], [1, 2, 7, 8], [1, 2, 7, 9], [1, 2, 7, 10], [1, 2, 8, 9], [1, 2, 8, 10], [1, 2, 9, 10], [1, 3, 4, 5], [1, 3, 4, 6], [1, 3, 4, 7], [1, 3, 4, 8], [1, 3, 4, 9], [1, 3, 4, 10], [1, 3, 5, 6], [1, 3, 5, 7], [1, 3, 5, 8], [1, 3, 5, 9], [1, 3, 5, 10], [1, 3, 6, 7], [1, 3, 6, 8], [1, 3, 6, 9], [1, 3, 6, 10], [1, 3, 7, 8], [1, 3, 7, 9], [1, 3, 7, 10], [1, 3, 8, 9], [1, 3, 8, 10], [1, 3, 9, 10], [1, 4, 5, 6], [1, 4, 5, 7], [1, 4, 5, 8], [1, 4, 5, 9], [1, 4, 5, 10], [1, 4, 6, 7], [1, 4, 6, 8], [1, 4, 6, 9], [1, 4, 6, 10], [1, 4, 7, 8], [1, 4, 7, 9], [1, 4, 7, 10], [1, 4, 8, 9], [1, 4, 8, 10], [1, 4, 9, 10], [1, 5, 6, 7], [1, 5, 6, 8], [1, 5, 6, 9], [1, 5, 6, 10], [1, 5, 7, 8], [1, 5, 7, 9], [1, 5, 7, 10], [1, 5, 8, 9], [1, 5, 8, 10], [1, 5, 9, 10], [1, 6, 7, 8], [1, 6, 7, 9], [1, 6, 7, 10], [1, 6, 8, 9], [1, 6, 8, 10], [1, 6, 9, 10], [1, 7, 8, 9], [1, 7, 8, 10], [1, 7, 9, 10], [1, 8, 9, 10], [2, 3, 4, 5], [2, 3, 4, 6], [2, 3, 4, 7], [2, 3, 4, 8], [2, 3, 4, 9], [2, 3, 4, 10], [2, 3, 5, 6], [2, 3, 5, 7], [2, 3, 5, 8], [2, 3, 5, 9], [2, 3, 5, 10], [2, 3, 6, 7], [2, 3, 6, 8], [2, 3, 6, 9], [2, 3, 6, 10], [2, 3, 7, 8], [2, 3, 7, 9], [2, 3, 7, 10], [2, 3, 8, 9], [2, 3, 8, 10], [2, 3, 9, 10], [2, 4, 5, 6], [2, 4, 5, 7], [2, 4, 5, 8], [2, 4, 5, 9], [2, 4, 5, 10], [2, 4, 6, 7], [2, 4, 6, 8], [2, 4, 6, 9], [2, 4, 6, 10], [2, 4, 7, 8], [2, 4, 7, 9], [2, 4, 7, 10], [2, 4, 8, 9], [2, 4, 8, 10], [2, 4, 9, 10], [2, 5, 6, 7], [2, 5, 6, 8], [2, 5, 6, 9], [2, 5, 6, 10], [2, 5, 7, 8], [2, 5, 7, 9], [2, 5, 7, 10], [2, 5, 8, 9], [2, 5, 8, 10], [2, 5, 9, 10], [2, 6, 7, 8], [2, 6, 7, 9], [2, 6, 7, 10], [2, 6, 8, 9], [2, 6, 8, 10], [2, 6, 9, 10], [2, 7, 8, 9], [2, 7, 8, 10], [2, 7, 9, 10], [2, 8, 9, 10], [3, 4, 5, 6], [3, 4, 5, 7], [3, 4, 5, 8], [3, 4, 5, 9], [3, 4, 5, 10], [3, 4, 6, 7], [3, 4, 6, 8], [3, 4, 6, 9], [3, 4, 6, 10], [3, 4, 7, 8], [3, 4, 7, 9], [3, 4, 7, 10], [3, 4, 8, 9], [3, 4, 8, 10], [3, 4, 9, 10], [3, 5, 6, 7], [3, 5, 6, 8], [3, 5, 6, 9], [3, 5, 6, 10], [3, 5, 7, 8], [3, 5, 7, 9], [3, 5, 7, 10], [3, 5, 8, 9], [3, 5, 8, 10], [3, 5, 9, 10], [3, 6, 7, 8], [3, 6, 7, 9], [3, 6, 7, 10], [3, 6, 8, 9], [3, 6, 8, 10], [3, 6, 9, 10], [3, 7, 8, 9], [3, 7, 8, 10], [3, 7, 9, 10], [3, 8, 9, 10], [4, 5, 6, 7], [4, 5, 6, 8], [4, 5, 6, 9], [4, 5, 6, 10], [4, 5, 7, 8], [4, 5, 7, 9], [4, 5, 7, 10], [4, 5, 8, 9], [4, 5, 8, 10], [4, 5, 9, 10], [4, 6, 7, 8], [4, 6, 7, 9], [4, 6, 7, 10], [4, 6, 8, 9], [4, 6, 8, 10], [4, 6, 9, 10], [4, 7, 8, 9], [4, 7, 8, 10], [4, 7, 9, 10], [4, 8, 9, 10], [5, 6, 7, 8], [5, 6, 7, 9], [5, 6, 7, 10], [5, 6, 8, 9], [5, 6, 8, 10], [5, 6, 9, 10], [5, 7, 8, 9], [5, 7, 8, 10], [5, 7, 9, 10], [5, 8, 9, 10], [6, 7, 8, 9], [6, 7, 8, 10], [6, 7, 9, 10], [6, 8, 9, 10], [7, 8, 9, 10]]
A5 = [[1, 2, 3, 4, 5], [1, 2, 3, 4, 6], [1, 2, 3, 4, 7], [1, 2, 3, 4, 8], [1, 2, 3, 4, 9], [1, 2, 3, 4, 10], [1, 2, 3, 5, 6], [1, 2, 3, 5, 7], [1, 2, 3, 5, 8], [1, 2, 3, 5, 9], [1, 2, 3, 5, 10], [1, 2, 3, 6, 7], [1, 2, 3, 6, 8], [1, 2, 3, 6, 9], [1, 2, 3, 6, 10], [1, 2, 3, 7, 8], [1, 2, 3, 7, 9], [1, 2, 3, 7, 10], [1, 2, 3, 8, 9], [1, 2, 3, 8, 10], [1, 2, 3, 9, 10], [1, 2, 4, 5, 6], [1, 2, 4, 5, 7], [1, 2, 4, 5, 8], [1, 2, 4, 5, 9], [1, 2, 4, 5, 10], [1, 2, 4, 6, 7], [1, 2, 4, 6, 8], [1, 2, 4, 6, 9], [1, 2, 4, 6, 10], [1, 2, 4, 7, 8], [1, 2, 4, 7, 9], [1, 2, 4, 7, 10], [1, 2, 4, 8, 9], [1, 2, 4, 8, 10], [1, 2, 4, 9, 10], [1, 2, 5, 6, 7], [1, 2, 5, 6, 8], [1, 2, 5, 6, 9], [1, 2, 5, 6, 10], [1, 2, 5, 7, 8], [1, 2, 5, 7, 9], [1, 2, 5, 7, 10], [1, 2, 5, 8, 9], [1, 2, 5, 8, 10], [1, 2, 5, 9, 10], [1, 2, 6, 7, 8], [1, 2, 6, 7, 9], [1, 2, 6, 7, 10], [1, 2, 6, 8, 9], [1, 2, 6, 8, 10], [1, 2, 6, 9, 10], [1, 2, 7, 8, 9], [1, 2, 7, 8, 10], [1, 2, 7, 9, 10], [1, 2, 8, 9, 10], [1, 3, 4, 5, 6], [1, 3, 4, 5, 7], [1, 3, 4, 5, 8], [1, 3, 4, 5, 9], [1, 3, 4, 5, 10], [1, 3, 4, 6, 7], [1, 3, 4, 6, 8], [1, 3, 4, 6, 9], [1, 3, 4, 6, 10], [1, 3, 4, 7, 8], [1, 3, 4, 7, 9], [1, 3, 4, 7, 10], [1, 3, 4, 8, 9], [1, 3, 4, 8, 10], [1, 3, 4, 9, 10], [1, 3, 5, 6, 7], [1, 3, 5, 6, 8], [1, 3, 5, 6, 9], [1, 3, 5, 6, 10], [1, 3, 5, 7, 8], [1, 3, 5, 7, 9], [1, 3, 5, 7, 10], [1, 3, 5, 8, 9], [1, 3, 5, 8, 10], [1, 3, 5, 9, 10], [1, 3, 6, 7, 8], [1, 3, 6, 7, 9], [1, 3, 6, 7, 10], [1, 3, 6, 8, 9], [1, 3, 6, 8, 10], [1, 3, 6, 9, 10], [1, 3, 7, 8, 9], [1, 3, 7, 8, 10], [1, 3, 7, 9, 10], [1, 3, 8, 9, 10], [1, 4, 5, 6, 7], [1, 4, 5, 6, 8], [1, 4, 5, 6, 9], [1, 4, 5, 6, 10], [1, 4, 5, 7, 8], [1, 4, 5, 7, 9], [1, 4, 5, 7, 10], [1, 4, 5, 8, 9], [1, 4, 5, 8, 10], [1, 4, 5, 9, 10], [1, 4, 6, 7, 8], [1, 4, 6, 7, 9], [1, 4, 6, 7, 10], [1, 4, 6, 8, 9], [1, 4, 6, 8, 10], [1, 4, 6, 9, 10], [1, 4, 7, 8, 9], [1, 4, 7, 8, 10], [1, 4, 7, 9, 10], [1, 4, 8, 9, 10], [1, 5, 6, 7, 8], [1, 5, 6, 7, 9], [1, 5, 6, 7, 10], [1, 5, 6, 8, 9], [1, 5, 6, 8, 10], [1, 5, 6, 9, 10], [1, 5, 7, 8, 9], [1, 5, 7, 8, 10], [1, 5, 7, 9, 10], [1, 5, 8, 9, 10], [1, 6, 7, 8, 9], [1, 6, 7, 8, 10], [1, 6, 7, 9, 10], [1, 6, 8, 9, 10], [1, 7, 8, 9, 10], [2, 3, 4, 5, 6], [2, 3, 4, 5, 7], [2, 3, 4, 5, 8], [2, 3, 4, 5, 9], [2, 3, 4, 5, 10], [2, 3, 4, 6, 7], [2, 3, 4, 6, 8], [2, 3, 4, 6, 9], [2, 3, 4, 6, 10], [2, 3, 4, 7, 8], [2, 3, 4, 7, 9], [2, 3, 4, 7, 10], [2, 3, 4, 8, 9], [2, 3, 4, 8, 10], [2, 3, 4, 9, 10], [2, 3, 5, 6, 7], [2, 3, 5, 6, 8], [2, 3, 5, 6, 9], [2, 3, 5, 6, 10], [2, 3, 5, 7, 8], [2, 3, 5, 7, 9], [2, 3, 5, 7, 10], [2, 3, 5, 8, 9], [2, 3, 5, 8, 10], [2, 3, 5, 9, 10], [2, 3, 6, 7, 8], [2, 3, 6, 7, 9], [2, 3, 6, 7, 10], [2, 3, 6, 8, 9], [2, 3, 6, 8, 10], [2, 3, 6, 9, 10], [2, 3, 7, 8, 9], [2, 3, 7, 8, 10], [2, 3, 7, 9, 10], [2, 3, 8, 9, 10], [2, 4, 5, 6, 7], [2, 4, 5, 6, 8], [2, 4, 5, 6, 9], [2, 4, 5, 6, 10], [2, 4, 5, 7, 8], [2, 4, 5, 7, 9], [2, 4, 5, 7, 10], [2, 4, 5, 8, 9], [2, 4, 5, 8, 10], [2, 4, 5, 9, 10], [2, 4, 6, 7, 8], [2, 4, 6, 7, 9], [2, 4, 6, 7, 10], [2, 4, 6, 8, 9], [2, 4, 6, 8, 10], [2, 4, 6, 9, 10], [2, 4, 7, 8, 9], [2, 4, 7, 8, 10], [2, 4, 7, 9, 10], [2, 4, 8, 9, 10], [2, 5, 6, 7, 8], [2, 5, 6, 7, 9], [2, 5, 6, 7, 10], [2, 5, 6, 8, 9], [2, 5, 6, 8, 10], [2, 5, 6, 9, 10], [2, 5, 7, 8, 9], [2, 5, 7, 8, 10], [2, 5, 7, 9, 10], [2, 5, 8, 9, 10], [2, 6, 7, 8, 9], [2, 6, 7, 8, 10], [2, 6, 7, 9, 10], [2, 6, 8, 9, 10], [2, 7, 8, 9, 10], [3, 4, 5, 6, 7], [3, 4, 5, 6, 8], [3, 4, 5, 6, 9], [3, 4, 5, 6, 10], [3, 4, 5, 7, 8], [3, 4, 5, 7, 9], [3, 4, 5, 7, 10], [3, 4, 5, 8, 9], [3, 4, 5, 8, 10], [3, 4, 5, 9, 10], [3, 4, 6, 7, 8], [3, 4, 6, 7, 9], [3, 4, 6, 7, 10], [3, 4, 6, 8, 9], [3, 4, 6, 8, 10], [3, 4, 6, 9, 10], [3, 4, 7, 8, 9], [3, 4, 7, 8, 10], [3, 4, 7, 9, 10], [3, 4, 8, 9, 10], [3, 5, 6, 7, 8], [3, 5, 6, 7, 9], [3, 5, 6, 7, 10], [3, 5, 6, 8, 9], [3, 5, 6, 8, 10], [3, 5, 6, 9, 10], [3, 5, 7, 8, 9], [3, 5, 7, 8, 10], [3, 5, 7, 9, 10], [3, 5, 8, 9, 10], [3, 6, 7, 8, 9], [3, 6, 7, 8, 10], [3, 6, 7, 9, 10], [3, 6, 8, 9, 10], [3, 7, 8, 9, 10], [4, 5, 6, 7, 8], [4, 5, 6, 7, 9], [4, 5, 6, 7, 10], [4, 5, 6, 8, 9], [4, 5, 6, 8, 10], [4, 5, 6, 9, 10], [4, 5, 7, 8, 9], [4, 5, 7, 8, 10], [4, 5, 7, 9, 10], [4, 5, 8, 9, 10], [4, 6, 7, 8, 9], [4, 6, 7, 8, 10], [4, 6, 7, 9, 10], [4, 6, 8, 9, 10], [4, 7, 8, 9, 10], [5, 6, 7, 8, 9], [5, 6, 7, 8, 10], [5, 6, 7, 9, 10], [5, 6, 8, 9, 10], [5, 7, 8, 9, 10], [6, 7, 8, 9, 10]]
A6 = [[1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 7], [1, 2, 3, 4, 5, 8], [1, 2, 3, 4, 5, 9], [1, 2, 3, 4, 5, 10], [1, 2, 3, 4, 6, 7], [1, 2, 3, 4, 6, 8], [1, 2, 3, 4, 6, 9], [1, 2, 3, 4, 6, 10], [1, 2, 3, 4, 7, 8], [1, 2, 3, 4, 7, 9], [1, 2, 3, 4, 7, 10], [1, 2, 3, 4, 8, 9], [1, 2, 3, 4, 8, 10], [1, 2, 3, 4, 9, 10], [1, 2, 3, 5, 6, 7], [1, 2, 3, 5, 6, 8], [1, 2, 3, 5, 6, 9], [1, 2, 3, 5, 6, 10], [1, 2, 3, 5, 7, 8], [1, 2, 3, 5, 7, 9], [1, 2, 3, 5, 7, 10], [1, 2, 3, 5, 8, 9], [1, 2, 3, 5, 8, 10], [1, 2, 3, 5, 9, 10], [1, 2, 3, 6, 7, 8], [1, 2, 3, 6, 7, 9], [1, 2, 3, 6, 7, 10], [1, 2, 3, 6, 8, 9], [1, 2, 3, 6, 8, 10], [1, 2, 3, 6, 9, 10], [1, 2, 3, 7, 8, 9], [1, 2, 3, 7, 8, 10], [1, 2, 3, 7, 9, 10], [1, 2, 3, 8, 9, 10], [1, 2, 4, 5, 6, 7], [1, 2, 4, 5, 6, 8], [1, 2, 4, 5, 6, 9], [1, 2, 4, 5, 6, 10], [1, 2, 4, 5, 7, 8], [1, 2, 4, 5, 7, 9], [1, 2, 4, 5, 7, 10], [1, 2, 4, 5, 8, 9], [1, 2, 4, 5, 8, 10], [1, 2, 4, 5, 9, 10], [1, 2, 4, 6, 7, 8], [1, 2, 4, 6, 7, 9], [1, 2, 4, 6, 7, 10], [1, 2, 4, 6, 8, 9], [1, 2, 4, 6, 8, 10], [1, 2, 4, 6, 9, 10], [1, 2, 4, 7, 8, 9], [1, 2, 4, 7, 8, 10], [1, 2, 4, 7, 9, 10], [1, 2, 4, 8, 9, 10], [1, 2, 5, 6, 7, 8], [1, 2, 5, 6, 7, 9], [1, 2, 5, 6, 7, 10], [1, 2, 5, 6, 8, 9], [1, 2, 5, 6, 8, 10], [1, 2, 5, 6, 9, 10], [1, 2, 5, 7, 8, 9], [1, 2, 5, 7, 8, 10], [1, 2, 5, 7, 9, 10], [1, 2, 5, 8, 9, 10], [1, 2, 6, 7, 8, 9], [1, 2, 6, 7, 8, 10], [1, 2, 6, 7, 9, 10], [1, 2, 6, 8, 9, 10], [1, 2, 7, 8, 9, 10], [1, 3, 4, 5, 6, 7], [1, 3, 4, 5, 6, 8], [1, 3, 4, 5, 6, 9], [1, 3, 4, 5, 6, 10], [1, 3, 4, 5, 7, 8], [1, 3, 4, 5, 7, 9], [1, 3, 4, 5, 7, 10], [1, 3, 4, 5, 8, 9], [1, 3, 4, 5, 8, 10], [1, 3, 4, 5, 9, 10], [1, 3, 4, 6, 7, 8], [1, 3, 4, 6, 7, 9], [1, 3, 4, 6, 7, 10], [1, 3, 4, 6, 8, 9], [1, 3, 4, 6, 8, 10], [1, 3, 4, 6, 9, 10], [1, 3, 4, 7, 8, 9], [1, 3, 4, 7, 8, 10], [1, 3, 4, 7, 9, 10], [1, 3, 4, 8, 9, 10], [1, 3, 5, 6, 7, 8], [1, 3, 5, 6, 7, 9], [1, 3, 5, 6, 7, 10], [1, 3, 5, 6, 8, 9], [1, 3, 5, 6, 8, 10], [1, 3, 5, 6, 9, 10], [1, 3, 5, 7, 8, 9], [1, 3, 5, 7, 8, 10], [1, 3, 5, 7, 9, 10], [1, 3, 5, 8, 9, 10], [1, 3, 6, 7, 8, 9], [1, 3, 6, 7, 8, 10], [1, 3, 6, 7, 9, 10], [1, 3, 6, 8, 9, 10], [1, 3, 7, 8, 9, 10], [1, 4, 5, 6, 7, 8], [1, 4, 5, 6, 7, 9], [1, 4, 5, 6, 7, 10], [1, 4, 5, 6, 8, 9], [1, 4, 5, 6, 8, 10], [1, 4, 5, 6, 9, 10], [1, 4, 5, 7, 8, 9], [1, 4, 5, 7, 8, 10], [1, 4, 5, 7, 9, 10], [1, 4, 5, 8, 9, 10], [1, 4, 6, 7, 8, 9], [1, 4, 6, 7, 8, 10], [1, 4, 6, 7, 9, 10], [1, 4, 6, 8, 9, 10], [1, 4, 7, 8, 9, 10], [1, 5, 6, 7, 8, 9], [1, 5, 6, 7, 8, 10], [1, 5, 6, 7, 9, 10], [1, 5, 6, 8, 9, 10], [1, 5, 7, 8, 9, 10], [1, 6, 7, 8, 9, 10], [2, 3, 4, 5, 6, 7], [2, 3, 4, 5, 6, 8], [2, 3, 4, 5, 6, 9], [2, 3, 4, 5, 6, 10], [2, 3, 4, 5, 7, 8], [2, 3, 4, 5, 7, 9], [2, 3, 4, 5, 7, 10], [2, 3, 4, 5, 8, 9], [2, 3, 4, 5, 8, 10], [2, 3, 4, 5, 9, 10], [2, 3, 4, 6, 7, 8], [2, 3, 4, 6, 7, 9], [2, 3, 4, 6, 7, 10], [2, 3, 4, 6, 8, 9], [2, 3, 4, 6, 8, 10], [2, 3, 4, 6, 9, 10], [2, 3, 4, 7, 8, 9], [2, 3, 4, 7, 8, 10], [2, 3, 4, 7, 9, 10], [2, 3, 4, 8, 9, 10], [2, 3, 5, 6, 7, 8], [2, 3, 5, 6, 7, 9], [2, 3, 5, 6, 7, 10], [2, 3, 5, 6, 8, 9], [2, 3, 5, 6, 8, 10], [2, 3, 5, 6, 9, 10], [2, 3, 5, 7, 8, 9], [2, 3, 5, 7, 8, 10], [2, 3, 5, 7, 9, 10], [2, 3, 5, 8, 9, 10], [2, 3, 6, 7, 8, 9], [2, 3, 6, 7, 8, 10], [2, 3, 6, 7, 9, 10], [2, 3, 6, 8, 9, 10], [2, 3, 7, 8, 9, 10], [2, 4, 5, 6, 7, 8], [2, 4, 5, 6, 7, 9], [2, 4, 5, 6, 7, 10], [2, 4, 5, 6, 8, 9], [2, 4, 5, 6, 8, 10], [2, 4, 5, 6, 9, 10], [2, 4, 5, 7, 8, 9], [2, 4, 5, 7, 8, 10], [2, 4, 5, 7, 9, 10], [2, 4, 5, 8, 9, 10], [2, 4, 6, 7, 8, 9], [2, 4, 6, 7, 8, 10], [2, 4, 6, 7, 9, 10], [2, 4, 6, 8, 9, 10], [2, 4, 7, 8, 9, 10], [2, 5, 6, 7, 8, 9], [2, 5, 6, 7, 8, 10], [2, 5, 6, 7, 9, 10], [2, 5, 6, 8, 9, 10], [2, 5, 7, 8, 9, 10], [2, 6, 7, 8, 9, 10], [3, 4, 5, 6, 7, 8], [3, 4, 5, 6, 7, 9], [3, 4, 5, 6, 7, 10], [3, 4, 5, 6, 8, 9], [3, 4, 5, 6, 8, 10], [3, 4, 5, 6, 9, 10], [3, 4, 5, 7, 8, 9], [3, 4, 5, 7, 8, 10], [3, 4, 5, 7, 9, 10], [3, 4, 5, 8, 9, 10], [3, 4, 6, 7, 8, 9], [3, 4, 6, 7, 8, 10], [3, 4, 6, 7, 9, 10], [3, 4, 6, 8, 9, 10], [3, 4, 7, 8, 9, 10], [3, 5, 6, 7, 8, 9], [3, 5, 6, 7, 8, 10], [3, 5, 6, 7, 9, 10], [3, 5, 6, 8, 9, 10], [3, 5, 7, 8, 9, 10], [3, 6, 7, 8, 9, 10], [4, 5, 6, 7, 8, 9], [4, 5, 6, 7, 8, 10], [4, 5, 6, 7, 9, 10], [4, 5, 6, 8, 9, 10], [4, 5, 7, 8, 9, 10], [4, 6, 7, 8, 9, 10], [5, 6, 7, 8, 9, 10]]
A7 = [[1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5, 6, 8], [1, 2, 3, 4, 5, 6, 9], [1, 2, 3, 4, 5, 6, 10], [1, 2, 3, 4, 5, 7, 8], [1, 2, 3, 4, 5, 7, 9], [1, 2, 3, 4, 5, 7, 10], [1, 2, 3, 4, 5, 8, 9], [1, 2, 3, 4, 5, 8, 10], [1, 2, 3, 4, 5, 9, 10], [1, 2, 3, 4, 6, 7, 8], [1, 2, 3, 4, 6, 7, 9], [1, 2, 3, 4, 6, 7, 10], [1, 2, 3, 4, 6, 8, 9], [1, 2, 3, 4, 6, 8, 10], [1, 2, 3, 4, 6, 9, 10], [1, 2, 3, 4, 7, 8, 9], [1, 2, 3, 4, 7, 8, 10], [1, 2, 3, 4, 7, 9, 10], [1, 2, 3, 4, 8, 9, 10], [1, 2, 3, 5, 6, 7, 8], [1, 2, 3, 5, 6, 7, 9], [1, 2, 3, 5, 6, 7, 10], [1, 2, 3, 5, 6, 8, 9], [1, 2, 3, 5, 6, 8, 10], [1, 2, 3, 5, 6, 9, 10], [1, 2, 3, 5, 7, 8, 9], [1, 2, 3, 5, 7, 8, 10], [1, 2, 3, 5, 7, 9, 10], [1, 2, 3, 5, 8, 9, 10], [1, 2, 3, 6, 7, 8, 9], [1, 2, 3, 6, 7, 8, 10], [1, 2, 3, 6, 7, 9, 10], [1, 2, 3, 6, 8, 9, 10], [1, 2, 3, 7, 8, 9, 10], [1, 2, 4, 5, 6, 7, 8], [1, 2, 4, 5, 6, 7, 9], [1, 2, 4, 5, 6, 7, 10], [1, 2, 4, 5, 6, 8, 9], [1, 2, 4, 5, 6, 8, 10], [1, 2, 4, 5, 6, 9, 10], [1, 2, 4, 5, 7, 8, 9], [1, 2, 4, 5, 7, 8, 10], [1, 2, 4, 5, 7, 9, 10], [1, 2, 4, 5, 8, 9, 10], [1, 2, 4, 6, 7, 8, 9], [1, 2, 4, 6, 7, 8, 10], [1, 2, 4, 6, 7, 9, 10], [1, 2, 4, 6, 8, 9, 10], [1, 2, 4, 7, 8, 9, 10], [1, 2, 5, 6, 7, 8, 9], [1, 2, 5, 6, 7, 8, 10], [1, 2, 5, 6, 7, 9, 10], [1, 2, 5, 6, 8, 9, 10], [1, 2, 5, 7, 8, 9, 10], [1, 2, 6, 7, 8, 9, 10], [1, 3, 4, 5, 6, 7, 8], [1, 3, 4, 5, 6, 7, 9], [1, 3, 4, 5, 6, 7, 10], [1, 3, 4, 5, 6, 8, 9], [1, 3, 4, 5, 6, 8, 10], [1, 3, 4, 5, 6, 9, 10], [1, 3, 4, 5, 7, 8, 9], [1, 3, 4, 5, 7, 8, 10], [1, 3, 4, 5, 7, 9, 10], [1, 3, 4, 5, 8, 9, 10], [1, 3, 4, 6, 7, 8, 9], [1, 3, 4, 6, 7, 8, 10], [1, 3, 4, 6, 7, 9, 10], [1, 3, 4, 6, 8, 9, 10], [1, 3, 4, 7, 8, 9, 10], [1, 3, 5, 6, 7, 8, 9], [1, 3, 5, 6, 7, 8, 10], [1, 3, 5, 6, 7, 9, 10], [1, 3, 5, 6, 8, 9, 10], [1, 3, 5, 7, 8, 9, 10], [1, 3, 6, 7, 8, 9, 10], [1, 4, 5, 6, 7, 8, 9], [1, 4, 5, 6, 7, 8, 10], [1, 4, 5, 6, 7, 9, 10], [1, 4, 5, 6, 8, 9, 10], [1, 4, 5, 7, 8, 9, 10], [1, 4, 6, 7, 8, 9, 10], [1, 5, 6, 7, 8, 9, 10], [2, 3, 4, 5, 6, 7, 8], [2, 3, 4, 5, 6, 7, 9], [2, 3, 4, 5, 6, 7, 10], [2, 3, 4, 5, 6, 8, 9], [2, 3, 4, 5, 6, 8, 10], [2, 3, 4, 5, 6, 9, 10], [2, 3, 4, 5, 7, 8, 9], [2, 3, 4, 5, 7, 8, 10], [2, 3, 4, 5, 7, 9, 10], [2, 3, 4, 5, 8, 9, 10], [2, 3, 4, 6, 7, 8, 9], [2, 3, 4, 6, 7, 8, 10], [2, 3, 4, 6, 7, 9, 10], [2, 3, 4, 6, 8, 9, 10], [2, 3, 4, 7, 8, 9, 10], [2, 3, 5, 6, 7, 8, 9], [2, 3, 5, 6, 7, 8, 10], [2, 3, 5, 6, 7, 9, 10], [2, 3, 5, 6, 8, 9, 10], [2, 3, 5, 7, 8, 9, 10], [2, 3, 6, 7, 8, 9, 10], [2, 4, 5, 6, 7, 8, 9], [2, 4, 5, 6, 7, 8, 10], [2, 4, 5, 6, 7, 9, 10], [2, 4, 5, 6, 8, 9, 10], [2, 4, 5, 7, 8, 9, 10], [2, 4, 6, 7, 8, 9, 10], [2, 5, 6, 7, 8, 9, 10], [3, 4, 5, 6, 7, 8, 9], [3, 4, 5, 6, 7, 8, 10], [3, 4, 5, 6, 7, 9, 10], [3, 4, 5, 6, 8, 9, 10], [3, 4, 5, 7, 8, 9, 10], [3, 4, 6, 7, 8, 9, 10], [3, 5, 6, 7, 8, 9, 10], [4, 5, 6, 7, 8, 9, 10]]
A8 = [[1, 2, 3, 4, 5, 6, 7, 8], [1, 2, 3, 4, 5, 6, 7, 9], [1, 2, 3, 4, 5, 6, 7, 10], [1, 2, 3, 4, 5, 6, 8, 9], [1, 2, 3, 4, 5, 6, 8, 10], [1, 2, 3, 4, 5, 6, 9, 10], [1, 2, 3, 4, 5, 7, 8, 9], [1, 2, 3, 4, 5, 7, 8, 10], [1, 2, 3, 4, 5, 7, 9, 10], [1, 2, 3, 4, 5, 8, 9, 10], [1, 2, 3, 4, 6, 7, 8, 9], [1, 2, 3, 4, 6, 7, 8, 10], [1, 2, 3, 4, 6, 7, 9, 10], [1, 2, 3, 4, 6, 8, 9, 10], [1, 2, 3, 4, 7, 8, 9, 10], [1, 2, 3, 5, 6, 7, 8, 9], [1, 2, 3, 5, 6, 7, 8, 10], [1, 2, 3, 5, 6, 7, 9, 10], [1, 2, 3, 5, 6, 8, 9, 10], [1, 2, 3, 5, 7, 8, 9, 10], [1, 2, 3, 6, 7, 8, 9, 10], [1, 2, 4, 5, 6, 7, 8, 9], [1, 2, 4, 5, 6, 7, 8, 10], [1, 2, 4, 5, 6, 7, 9, 10], [1, 2, 4, 5, 6, 8, 9, 10], [1, 2, 4, 5, 7, 8, 9, 10], [1, 2, 4, 6, 7, 8, 9, 10], [1, 2, 5, 6, 7, 8, 9, 10], [1, 3, 4, 5, 6, 7, 8, 9], [1, 3, 4, 5, 6, 7, 8, 10], [1, 3, 4, 5, 6, 7, 9, 10], [1, 3, 4, 5, 6, 8, 9, 10], [1, 3, 4, 5, 7, 8, 9, 10], [1, 3, 4, 6, 7, 8, 9, 10], [1, 3, 5, 6, 7, 8, 9, 10], [1, 4, 5, 6, 7, 8, 9, 10], [2, 3, 4, 5, 6, 7, 8, 9], [2, 3, 4, 5, 6, 7, 8, 10], [2, 3, 4, 5, 6, 7, 9, 10], [2, 3, 4, 5, 6, 8, 9, 10], [2, 3, 4, 5, 7, 8, 9, 10], [2, 3, 4, 6, 7, 8, 9, 10], [2, 3, 5, 6, 7, 8, 9, 10], [2, 4, 5, 6, 7, 8, 9, 10], [3, 4, 5, 6, 7, 8, 9, 10]]
A9 = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 5, 6, 7, 8, 10], [1, 2, 3, 4, 5, 6, 7, 9, 10], [1, 2, 3, 4, 5, 6, 8, 9, 10], [1, 2, 3, 4, 5, 7, 8, 9, 10], [1, 2, 3, 4, 6, 7, 8, 9, 10], [1, 2, 3, 5, 6, 7, 8, 9, 10], [1, 2, 4, 5, 6, 7, 8, 9, 10], [1, 3, 4, 5, 6, 7, 8, 9, 10], [2, 3, 4, 5, 6, 7, 8, 9, 10]]
A10 = [[1,2,3,4,5,6,7,8,9,10]]
A = [A2,A3,A4,A5,A6,A7,A8,A9,A10]

total = 0
for a in A[n-2]:
    for test in a :
        if test > m :
            continue
    
    tmp = 0
    for i in range(q):
        if a[X[i][1]-1] - a[X[i][0]-1] == X[i][2]:
            tmp += X[i][3]
    total = max(tmp , total)

print(total)

Submission status: Wrong Answer

Solution code:
#入力
A,B,N=map(lambda x:int(x),input().split())

Max=0
x=1
for x in range(N+1):
	num=int(A*x/B)-A*int(x/B)
	if num>=Max:
		Max=num
	x=x+1
print(Max)

Submission status: Wrong Answer

Solution code:
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
import itertools

N, M, Q = MAP()
a, b, c, d = [], [], [], []
for _ in range(Q):
    ai, bi, ci, di = MAP()
    a.append(ai-1); b.append(bi-1); c.append(ci); d.append(di)


def solve(lst):
    ans = 0
    for i in range(Q):
        if lst[b[i]] - lst[a[i]] == c[i]:
            ans += d[i]
    return ans

ans = 0
for A in itertools.combinations(range(1, 11), N):
    ans = max(ans, solve(A))

print(ans)

Submission status: Wrong Answer

Solution code:
n,m,q = map(int,input().split())
a = []
b = []
c = []
d = []
for i in range(q):
    e,f,g,h = map(int,input().split())
    a.append(e)
    b.append(f)
    c.append(g)
    d.append(h)

counter = 0
for i in range(n-1):
    counter += m - 1
    m -= 1

sum_c = 0
count = 0
for i in sorted(c):
    sum_c += i
    if sum_c > counter:
        break
    count += 1

d_count = 1
ans = 0
for i in sorted(d,reverse = True):
    if d_count > count:
        break
    ans += i
    d_count += 1


print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat May  2 22:20:58 2020

@author: Masataka Amau
"""

import sys
sys.setrecursionlimit(20000)
A = []
B = []
C = []
D = []
(N, M, Q) = map(int, input().split())
for i in range(Q):
  (aa, bb, cc, dd) = map(int, input().split())
  A.append(aa)
  B.append(bb)
  C.append(cc)
  D.append(dd)
ansvec = [0, 0, 0, 0, 0 ,0 ,0 ,0 ,0 ,0]
answer = 0

def assess():
    ans = 0
    for i in range(Q):
        if(ansvec[B[i] - 1] - ansvec[A[i] - 1] == C[i]):
            ans+=D[i]
    return ans

def LOOP(idx, n):
    global answer
    if(idx == N - 1):
        for i in range(n, M):
            ansvec[idx] = i
            buf= assess()
            if(answer < buf):
                answer = buf
    else:
        for i in range(n, M):
            ansvec[idx] = i
            LOOP(idx + 1, n)

LOOP(0, 0)
print(answer)