--- /dev/null
+games = [(1, 2),
+ (1, 3),
+ (1, 4),
+ (2, 3),
+ (2, 4),
+ (3, 4)]
+seen = set()
+
+team = {1: 0, 2: 0, 3: 0, 4: 0}
+
+T = int(input())
+G = int(input())
+for i in range(G):
+ A, B, SA, SB = tuple(map(int, input().split()))
+ seen.add((A, B))
+ seen.add((B, A))
+ if SA > SB:
+ team[A] += 3
+ elif SA == SB:
+ team[A] += 1
+ team[B] += 1
+ else:
+ team[B] += 3
+
+unplayed = []
+for i in games:
+ if i not in seen:
+ unplayed.append(i)
+
+wins = [0]
+
+
+def dfs(node, depth):
+ if depth == len(unplayed):
+ tied = False
+ winning_team = 0
+ most_points = 0
+ for i in node:
+ if node[i] > most_points:
+ most_points = node[i]
+ winning_team = i
+ tied = False
+ elif node[i] == most_points:
+ tied = True
+
+ if not tied and winning_team == T:
+ wins[0] += 1
+
+ return
+
+ current = node.copy()
+ A, B = unplayed[depth]
+ current[A] += 3
+ dfs(current, depth + 1)
+ current[A] -= 2
+ current[B] += 1
+ dfs(current, depth + 1)
+ current[B] += 2
+ current[A] -= 1
+ dfs(current, depth + 1)
+
+
+dfs(team, 0)
+print(wins[0])
+test = {1:0,2:1,3:-1}
+print(max(test.values()))
+
+
+# test = {1,2,3}
+# test2 = test
+# test3 = test.copy()
+#
+# # test2.add(4)
+# test3.add(4)
+#
+# print(test)
+# print(test2)
+# print(test3)
+
+# test = [1,2,3,4]
+#
+# def shift(t, val):
+# for i in range(3):
+# t[i] = t[i+1]
+# t[-1] = val
+#
+# shift(test,5)
+# print(test)
+
+
# test = {"A":'a', "B":'b'}
#
# if "A" in test:
# a = [1,2,3]
# print(a[:-1])
-test = {"A":{1,2,3}, 1:[1,1]}
-
-test["A"].remove(1)
-
-
-test2 = test.copy()
-
-test2["B"] = 1
-test2[1].append(2)
-
-print(test)
-print(test2)
+# test = {"A":{1,2,3}, 1:[1,1]}
+#
+# test["A"].remove(1)
+#
+#
+# test2 = test.copy()
+#
+# test2["B"] = 1
+# test2[1].append(2)
+#
+# print(test)
+# print(test2)