id
stringlengths
14
117
description
stringlengths
29
13k
code
stringlengths
10
49.8k
test_samples
sequence
source
class label
3 classes
prompt
stringlengths
391
104k
1037_E. Trips_10
There are n persons who initially don't know each other. On each morning, two of them, who were not friends before, become friends. We want to plan a trip for every evening of m days. On each trip, you have to select a group of people that will go on the trip. For every person, one of the following should hold: * Either this person does not go on the trip, * Or at least k of his friends also go on the trip. Note that the friendship is not transitive. That is, if a and b are friends and b and c are friends, it does not necessarily imply that a and c are friends. For each day, find the maximum number of people that can go on the trip on that day. Input The first line contains three integers n, m, and k (2 ≀ n ≀ 2 β‹… 10^5, 1 ≀ m ≀ 2 β‹… 10^5, 1 ≀ k < n) β€” the number of people, the number of days and the number of friends each person on the trip should have in the group. The i-th (1 ≀ i ≀ m) of the next m lines contains two integers x and y (1≀ x, y≀ n, xβ‰  y), meaning that persons x and y become friends on the morning of day i. It is guaranteed that x and y were not friends before. Output Print exactly m lines, where the i-th of them (1≀ i≀ m) contains the maximum number of people that can go on the trip on the evening of the day i. Examples Input 4 4 2 2 3 1 2 1 3 1 4 Output 0 0 3 3 Input 5 8 2 2 1 4 2 5 4 5 2 4 3 5 1 4 1 3 2 Output 0 0 0 3 3 4 4 5 Input 5 7 2 1 5 3 2 2 5 3 4 1 2 5 3 1 3 Output 0 0 0 0 3 4 4 Note In the first example, * 1,2,3 can go on day 3 and 4. In the second example, * 2,4,5 can go on day 4 and 5. * 1,2,4,5 can go on day 6 and 7. * 1,2,3,4,5 can go on day 8. In the third example, * 1,2,5 can go on day 5. * 1,2,3,5 can go on day 6 and 7.
from collections import deque def solve(adj, m, k, uv): n = len(adj) nn = [len(a) for a in adj] q = deque() for i in range(n): if nn[i] < k: q.append(i) while q: v = q.popleft() for u in adj[v]: nn[u] -= 1 if nn[u] == k-1: q.append(u) res = [0]*m nk = len([1 for i in nn if i >= k]) res[-1] = nk for i in range(m-1, 0, -1): u1, v1 = uv[i] if nn[u1] < k or nn[v1] < k: res[i - 1] = nk continue if nn[u1] == k: q.append(u1) nn[u1] -= 1 if not q and nn[v1] == k: q.append(v1) nn[v1] -= 1 if not q: nn[u1] -= 1 nn[v1] -= 1 adj[u1].remove(v1) adj[v1].remove(u1) while q: v = q.popleft() nk -= 1 for u in adj[v]: nn[u] -= 1 if nn[u] == k - 1: q.append(u) res[i - 1] = nk return res n, m, k = map(int, input().split()) a = [set() for i in range(n)] uv = [] for i in range(m): u, v = map(int, input().split()) a[u - 1].add(v - 1) a[v - 1].add(u - 1) uv.append((u-1, v-1)) res = solve(a, m, k, uv) print(str(res)[1:-1].replace(' ', '').replace(',', '\n'))
{ "input": [ "4 4 2\n2 3\n1 2\n1 3\n1 4\n", "5 8 2\n2 1\n4 2\n5 4\n5 2\n4 3\n5 1\n4 1\n3 2\n", "5 7 2\n1 5\n3 2\n2 5\n3 4\n1 2\n5 3\n1 3\n", "16 20 2\n10 3\n5 3\n10 5\n12 7\n7 6\n9 12\n9 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n4 13\n13 15\n1 8\n7 15\n1 7\n8 15\n", "2 1 1\n2 1\n", "16 20 2\n10 3\n5 3\n10 5\n12 7\n7 6\n9 10\n9 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n4 13\n13 15\n1 8\n7 15\n1 7\n8 15\n", "16 20 2\n10 3\n5 3\n10 5\n12 7\n7 6\n9 10\n2 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n4 13\n13 15\n1 8\n7 15\n1 7\n8 15\n", "16 20 2\n10 4\n5 3\n10 5\n12 7\n7 6\n9 12\n9 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n4 13\n13 15\n1 8\n7 15\n1 7\n8 15\n", "9 8 2\n2 1\n4 2\n5 4\n5 2\n4 3\n5 1\n4 1\n3 2\n", "16 20 2\n10 3\n5 3\n10 5\n12 7\n7 6\n9 10\n2 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n4 3\n13 15\n1 8\n7 15\n1 7\n8 15\n", "2 1 2\n2 1\n", "16 20 2\n10 3\n5 3\n10 5\n12 7\n7 6\n9 10\n2 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n3 13\n13 15\n1 8\n7 15\n1 7\n8 15\n", "16 20 2\n10 4\n5 3\n10 5\n12 7\n7 6\n9 12\n9 6\n1 10\n11 16\n11 1\n16 3\n10 2\n14 4\n15 14\n4 13\n13 15\n1 8\n7 15\n1 7\n8 15\n", "16 20 2\n10 3\n5 3\n10 5\n12 7\n7 6\n9 10\n2 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n4 3\n13 15\n1 14\n7 15\n1 7\n8 15\n", "16 20 2\n10 3\n5 3\n10 5\n12 7\n7 6\n9 10\n2 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n3 13\n1 15\n1 8\n7 15\n1 7\n8 15\n", "16 20 2\n10 3\n5 3\n11 5\n12 7\n7 6\n9 10\n2 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n4 3\n13 15\n1 14\n7 15\n1 7\n8 15\n", "27 20 2\n10 3\n5 3\n20 5\n12 7\n7 6\n9 10\n2 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n3 13\n1 15\n1 8\n7 15\n1 7\n8 15\n", "27 20 3\n10 3\n5 1\n20 5\n12 7\n7 6\n9 10\n2 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n3 13\n1 15\n1 8\n7 15\n1 7\n8 15\n", "16 20 2\n10 3\n5 3\n10 5\n12 3\n7 6\n9 12\n9 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n4 13\n13 15\n1 8\n7 15\n1 7\n8 15\n", "9 7 2\n1 5\n3 2\n2 5\n3 4\n1 2\n5 3\n1 3\n", "16 20 2\n10 3\n5 3\n10 5\n12 7\n7 6\n9 10\n2 6\n1 10\n11 16\n11 2\n16 2\n10 2\n14 4\n15 14\n4 13\n13 15\n1 8\n7 15\n1 7\n8 15\n", "16 20 2\n10 4\n5 3\n10 5\n12 7\n7 6\n9 12\n9 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n4 12\n13 15\n1 8\n7 15\n1 7\n8 15\n", "16 20 2\n10 4\n5 3\n10 5\n12 7\n7 6\n9 12\n9 6\n1 10\n11 16\n11 1\n9 3\n10 2\n14 4\n15 14\n4 13\n13 15\n1 8\n7 15\n1 7\n8 15\n", "16 20 2\n10 3\n5 3\n13 5\n12 7\n7 6\n9 10\n2 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n4 3\n13 15\n1 14\n7 15\n1 7\n8 15\n", "16 20 2\n10 3\n5 3\n10 5\n12 7\n7 6\n9 10\n2 5\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n3 13\n1 15\n1 8\n7 15\n1 7\n8 15\n", "16 20 2\n10 4\n5 3\n10 5\n12 7\n7 6\n9 12\n9 6\n1 10\n11 16\n11 1\n16 3\n10 3\n14 4\n15 14\n4 13\n13 3\n1 8\n7 15\n1 7\n8 15\n", "16 20 2\n10 3\n5 3\n11 9\n12 7\n7 6\n9 10\n2 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n4 3\n13 15\n1 14\n7 15\n1 7\n8 15\n", "9 7 2\n1 5\n4 2\n2 5\n3 4\n1 2\n5 3\n1 3\n", "16 20 2\n10 4\n5 3\n10 5\n12 7\n7 6\n9 12\n9 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n6 12\n13 15\n1 8\n7 15\n1 7\n8 15\n", "16 20 2\n10 3\n5 3\n11 9\n12 7\n7 6\n9 10\n2 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n4 3\n13 15\n1 14\n3 15\n1 7\n8 15\n", "9 8 2\n2 1\n4 2\n5 4\n5 2\n4 3\n5 1\n7 1\n3 2\n", "16 20 2\n10 4\n5 3\n10 5\n12 7\n7 6\n9 12\n9 6\n1 10\n11 16\n11 1\n16 3\n10 3\n14 4\n15 14\n4 13\n13 15\n1 8\n7 15\n1 7\n8 15\n", "27 20 2\n10 3\n5 3\n10 5\n12 7\n7 6\n9 10\n2 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n3 13\n1 15\n1 8\n7 15\n1 7\n8 15\n", "27 20 2\n10 3\n5 1\n20 5\n12 7\n7 6\n9 10\n2 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n3 13\n1 15\n1 8\n7 15\n1 7\n8 15\n", "27 20 3\n10 3\n5 1\n20 5\n12 7\n7 6\n12 10\n2 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n3 13\n1 15\n1 8\n7 15\n1 7\n8 15\n", "27 20 3\n10 3\n5 1\n20 5\n12 5\n7 6\n12 10\n2 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n3 13\n1 15\n1 8\n7 15\n1 7\n8 15\n", "27 20 3\n10 3\n5 1\n20 5\n12 5\n7 6\n12 10\n2 6\n1 10\n11 16\n11 1\n16 4\n10 2\n14 4\n15 14\n3 13\n1 15\n1 8\n7 15\n1 7\n8 15\n", "27 20 3\n10 3\n5 1\n20 5\n12 5\n13 6\n12 10\n2 6\n1 10\n11 16\n11 1\n16 4\n10 2\n14 4\n15 14\n3 13\n1 15\n1 8\n7 15\n1 7\n8 15\n", "27 20 3\n10 3\n5 1\n20 5\n12 5\n13 6\n12 10\n2 6\n1 10\n11 16\n11 1\n16 4\n3 2\n14 4\n15 14\n3 13\n1 15\n1 8\n7 15\n1 7\n8 15\n", "2 1 3\n2 1\n", "27 20 2\n10 3\n5 3\n10 5\n12 7\n7 6\n9 10\n2 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n19 14\n3 13\n1 15\n1 8\n7 15\n1 7\n8 15\n", "27 20 2\n10 3\n5 3\n20 5\n12 7\n7 6\n9 10\n2 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 23\n3 13\n1 15\n1 8\n7 15\n1 7\n8 15\n", "27 20 2\n10 3\n5 1\n20 5\n12 7\n7 6\n9 10\n2 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n3 13\n1 15\n1 8\n7 15\n1 7\n8 16\n", "27 20 3\n10 3\n5 1\n20 2\n12 7\n7 6\n9 10\n2 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n3 13\n1 15\n1 8\n7 15\n1 7\n8 15\n", "27 20 3\n10 3\n5 1\n20 5\n12 7\n7 6\n12 10\n2 6\n1 10\n11 16\n11 1\n16 2\n10 2\n25 4\n15 14\n3 13\n1 15\n1 8\n7 15\n1 7\n8 15\n", "27 20 3\n10 3\n5 1\n20 7\n12 5\n7 6\n12 10\n2 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n3 13\n1 15\n1 8\n7 15\n1 7\n8 15\n", "27 20 3\n10 3\n5 1\n20 5\n12 5\n13 6\n12 10\n2 6\n1 10\n11 16\n11 1\n16 4\n10 2\n14 4\n15 24\n3 13\n1 15\n1 8\n7 15\n1 7\n8 15\n", "27 20 3\n10 3\n5 1\n20 5\n12 5\n13 6\n12 10\n3 6\n1 10\n11 16\n11 1\n16 4\n3 2\n14 4\n15 14\n3 13\n1 15\n1 8\n7 15\n1 7\n8 15\n", "16 20 2\n10 3\n5 3\n13 5\n12 7\n7 6\n9 10\n2 6\n1 10\n11 16\n11 1\n16 2\n10 2\n14 4\n15 14\n4 3\n13 15\n2 14\n7 15\n1 7\n8 15\n", "16 20 2\n10 4\n5 3\n10 5\n12 7\n7 6\n9 12\n9 6\n1 10\n11 16\n11 1\n16 3\n10 3\n14 4\n15 14\n4 13\n13 3\n1 8\n7 15\n2 7\n8 15\n" ], "output": [ "0\n0\n3\n3\n", "0\n0\n0\n3\n3\n4\n4\n5\n", "0\n0\n0\n0\n3\n4\n4\n", "0\n0\n3\n3\n3\n3\n7\n7\n7\n7\n7\n11\n11\n11\n11\n15\n15\n15\n15\n16\n", "2\n", "0\n0\n3\n3\n3\n3\n3\n3\n3\n3\n3\n7\n7\n7\n7\n11\n11\n14\n14\n15\n", "0\n0\n3\n3\n3\n3\n3\n3\n3\n3\n3\n7\n7\n7\n7\n11\n11\n13\n13\n14\n", "0\n0\n0\n0\n0\n0\n4\n4\n4\n4\n4\n9\n9\n9\n9\n13\n13\n13\n13\n14\n", "0\n0\n0\n3\n3\n4\n4\n5\n", "0\n0\n3\n3\n3\n3\n3\n3\n3\n3\n3\n7\n7\n7\n7\n7\n7\n12\n12\n13\n", "0\n", "0\n0\n3\n3\n3\n3\n3\n3\n3\n3\n3\n7\n7\n7\n7\n7\n7\n11\n11\n12\n", "0\n0\n0\n0\n0\n0\n4\n4\n4\n4\n10\n10\n10\n10\n10\n14\n14\n14\n14\n15\n", "0\n0\n3\n3\n3\n3\n3\n3\n3\n3\n3\n7\n7\n7\n7\n7\n9\n12\n12\n12\n", "0\n0\n3\n3\n3\n3\n3\n3\n3\n3\n3\n7\n7\n7\n7\n7\n7\n10\n10\n11\n", "0\n0\n0\n0\n0\n0\n0\n0\n0\n5\n5\n7\n7\n7\n7\n7\n9\n12\n12\n12\n", "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n5\n5\n5\n5\n5\n5\n8\n8\n9\n", "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n", "0\n0\n3\n3\n3\n3\n3\n3\n3\n3\n3\n7\n7\n7\n7\n11\n11\n15\n15\n16\n", "0\n0\n0\n0\n3\n4\n4\n", "0\n0\n3\n3\n3\n3\n3\n3\n3\n3\n6\n6\n6\n6\n6\n10\n10\n12\n13\n14\n", "0\n0\n0\n0\n0\n0\n4\n4\n4\n4\n4\n9\n9\n9\n10\n10\n10\n12\n12\n13\n", "0\n0\n0\n0\n0\n0\n4\n4\n4\n4\n4\n4\n4\n4\n4\n11\n11\n11\n12\n13\n", "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n5\n5\n5\n5\n11\n11\n13\n13\n13\n", "0\n0\n3\n3\n3\n3\n3\n3\n3\n3\n7\n7\n7\n7\n7\n7\n7\n7\n9\n10\n", "0\n0\n0\n0\n0\n0\n4\n4\n4\n4\n10\n10\n10\n10\n10\n12\n12\n14\n14\n15\n", "0\n0\n0\n0\n0\n0\n0\n0\n0\n4\n4\n6\n6\n6\n6\n6\n9\n12\n12\n12\n", "0\n0\n0\n0\n3\n5\n5\n", "0\n0\n0\n0\n0\n0\n4\n4\n4\n4\n4\n9\n9\n9\n9\n9\n9\n12\n12\n13\n", "0\n0\n0\n0\n0\n0\n0\n0\n0\n4\n4\n6\n6\n6\n6\n6\n9\n10\n12\n12\n", "0\n0\n0\n3\n3\n4\n4\n5\n", "0\n0\n0\n0\n0\n0\n4\n4\n4\n4\n10\n10\n10\n10\n10\n14\n14\n14\n14\n15\n", "0\n0\n3\n3\n3\n3\n3\n3\n3\n3\n3\n7\n7\n7\n7\n7\n7\n10\n10\n11\n", "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n5\n5\n5\n5\n5\n5\n8\n8\n9\n", "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n", "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n", "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n", "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n", "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n", "0\n", "0\n0\n3\n3\n3\n3\n3\n3\n3\n3\n3\n7\n7\n7\n7\n7\n7\n10\n10\n11\n", "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n5\n5\n5\n5\n5\n5\n8\n8\n9\n", "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n5\n5\n5\n5\n5\n5\n8\n8\n9\n", "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n", "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n", "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n", "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n", "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n", "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n5\n5\n5\n5\n11\n11\n13\n13\n13\n", "0\n0\n0\n0\n0\n0\n4\n4\n4\n4\n10\n10\n10\n10\n10\n12\n12\n14\n14\n15\n" ] }
2CODEFORCES
Below is a problem description that describes the problem. Write code in Python that appropriately solves the problem. ### Description: There are n persons who initially don't know each other. On each morning, two of them, who were not friends before, become friends. We want to plan a trip for every evening of m days. On each trip, you have to select a group of people that will go on the trip. For every person, one of the following should hold: * Either this person does not go on the trip, * Or at least k of his friends also go on the trip. Note that the friendship is not transitive. That is, if a and b are friends and b and c are friends, it does not necessarily imply that a and c are friends. For each day, find the maximum number of people that can go on the trip on that day. Input The first line contains three integers n, m, and k (2 ≀ n ≀ 2 β‹… 10^5, 1 ≀ m ≀ 2 β‹… 10^5, 1 ≀ k < n) β€” the number of people, the number of days and the number of friends each person on the trip should have in the group. The i-th (1 ≀ i ≀ m) of the next m lines contains two integers x and y (1≀ x, y≀ n, xβ‰  y), meaning that persons x and y become friends on the morning of day i. It is guaranteed that x and y were not friends before. Output Print exactly m lines, where the i-th of them (1≀ i≀ m) contains the maximum number of people that can go on the trip on the evening of the day i. Examples Input 4 4 2 2 3 1 2 1 3 1 4 Output 0 0 3 3 Input 5 8 2 2 1 4 2 5 4 5 2 4 3 5 1 4 1 3 2 Output 0 0 0 3 3 4 4 5 Input 5 7 2 1 5 3 2 2 5 3 4 1 2 5 3 1 3 Output 0 0 0 0 3 4 4 Note In the first example, * 1,2,3 can go on day 3 and 4. In the second example, * 2,4,5 can go on day 4 and 5. * 1,2,4,5 can go on day 6 and 7. * 1,2,3,4,5 can go on day 8. In the third example, * 1,2,5 can go on day 5. * 1,2,3,5 can go on day 6 and 7. ### Input: 4 4 2 2 3 1 2 1 3 1 4 ### Output: 0 0 3 3 ### Input: 5 8 2 2 1 4 2 5 4 5 2 4 3 5 1 4 1 3 2 ### Output: 0 0 0 3 3 4 4 5 ### Code: from collections import deque def solve(adj, m, k, uv): n = len(adj) nn = [len(a) for a in adj] q = deque() for i in range(n): if nn[i] < k: q.append(i) while q: v = q.popleft() for u in adj[v]: nn[u] -= 1 if nn[u] == k-1: q.append(u) res = [0]*m nk = len([1 for i in nn if i >= k]) res[-1] = nk for i in range(m-1, 0, -1): u1, v1 = uv[i] if nn[u1] < k or nn[v1] < k: res[i - 1] = nk continue if nn[u1] == k: q.append(u1) nn[u1] -= 1 if not q and nn[v1] == k: q.append(v1) nn[v1] -= 1 if not q: nn[u1] -= 1 nn[v1] -= 1 adj[u1].remove(v1) adj[v1].remove(u1) while q: v = q.popleft() nk -= 1 for u in adj[v]: nn[u] -= 1 if nn[u] == k - 1: q.append(u) res[i - 1] = nk return res n, m, k = map(int, input().split()) a = [set() for i in range(n)] uv = [] for i in range(m): u, v = map(int, input().split()) a[u - 1].add(v - 1) a[v - 1].add(u - 1) uv.append((u-1, v-1)) res = solve(a, m, k, uv) print(str(res)[1:-1].replace(' ', '').replace(',', '\n'))
1060_A. Phone Numbers_14
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards.
n = int(input()) s = input() k = s.count("8") l = n - k if k <= l//10: print(k) else: while k > l//10: k -= 1 l += 1 print(min(k, l//10))
{ "input": [ "22\n0011223344556677889988\n", "11\n00000000008\n", "11\n31415926535\n", "51\n882889888888689888850888388887688788888888888858888\n", "55\n7271714707719515303911625619272900050990324951111943573\n", "72\n888488888888823288848804883838888888887888888888228888218488897809784868\n", "65\n44542121362830719677175203560438858260878894083124543850593761845\n", "54\n438283821340622774637957966575424773837418828888614203\n", "100\n1976473621569903172721407763737179639055561746310369779167351419713916160700096173622427077757986026\n", "100\n2833898888858387469888804083887280788584887487186899808436848018181838884988432785338497585788803883\n", "42\n885887846290886288816884858898812858495482\n", "75\n878909759892888846183608689257806813376950958863798487856148633095072259838\n", "11\n55814018693\n", "31\n0868889888343881888987888838808\n", "21\n888888888888000000000\n", "62\n18888883884288488882387888486858887882838885288886472818688888\n", "77\n11111111111111111111111111111111111111111111111111111111111111111111111111111\n", "30\n888888888888888888888888888888\n", "64\n8885984815868480968883818886281846682409262501034555933863969284\n", "44\n15920309219313427633220119270900111650391207\n", "97\n4088468966684435599488804806521288358953088399738904557539253573051442198885776802972628197705081\n", "100\n8800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "50\n88888888888888888888888888888888888888888888888888\n", "20\n88888888888888888888\n", "32\n88888888888888888888888888888888\n", "82\n8889809888888888485881851986857288588888888881988888868888836888887858888888888878\n", "91\n8828880888888884883888488888888888888881888888888884888888848588888808888888888888888880888\n", "87\n311753415808202195240425076966761033489788093280714672959929008324554784724650182457298\n", "85\n6888887655188885918863889822590788834182048952565514598298586848861396753319582883848\n", "100\n8088888818885808888888848829886788884187188858898888888788988688884828586988888888288078638898728181\n", "21\n888111111111111111111\n", "1\n8\n", "93\n888088898748888038885888818882806848806887888888882087481868888888177809288888889648468888188\n", "77\n11233392925013001334679215120076714945221576003953746107506364475115045309091\n", "40\n8888888888888888888888888888888888888888\n", "33\n888800000000000000000000000000000\n", "21\n881234567900123456790\n", "98\n87247250157776241281197787785951754485531639139778166755966603305697265958800376912432893847612736\n", "90\n888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "22\n4215079217017196952791\n", "99\n509170332523502565755650047942914747120102240396245453406790272793996913905060450414255616791704320\n", "96\n812087553199958040928832802441581868680188987878748641868838838835609806814288472573117388803351\n", "1\n0\n", "100\n8888888888828188888888888888888808888888888888888888891888888768888888888288888885886888838888888888\n", "11\n80000000000\n", "86\n84065885114540280210185082984888812185222886689129308815942798404861082196041321701260\n", "92\n86888880558884738878888381088888888895888881888888888368878888888884888768881888888888808888\n", "76\n7900795570936733366353829649382870728119825830883973668601071678041634916557\n", "32\n88000000000000000000000000000000\n", "70\n8888888888888888888888888888888888888888888888888888888888888888888888\n", "11\n88888888888\n", "21\n888000000000000000000\n", "66\n747099435917145962031075767196746707764157706291155762576312312094\n", "22\n8899999999999999999999\n", "11\n81234567123\n", "41\n78888884888874788841882882888088888588888\n", "10\n8888888888\n", "100\n2867878187889776883889958480848802884888888878218089281860321588888888987288888884288488988628618888\n", "66\n157941266854773786962397310504192100434183957442977444078457168272\n", "44\n30153452341853403190257244993442815171970194\n", "63\n728385948188688801288285888788852829888898565895847689806684688\n", "100\n1835563855281170226095294644116563180561156535623048783710060508361834822227075869575873675232708159\n", "21\n888888555555555555555\n", "100\n8881888389882878867888888888888888888886388888888870888884878888089888883898887888808688888487888888\n", "53\n85838985300863473289888099788588319484149888886832906\n", "60\n888888888888888888888888888888888888888888888888888888888888\n", "100\n8820286285185244938452488887088871457098945874486988698468788381417332842888928188688887641132194956\n", "11\n24572366390\n", "84\n181288888282608548858058871581888853888486785801381108858832882809848798828837386086\n", "32\n88257478884887437239023185588797\n", "99\n097167815527663544905782574817314139311067328533970663873718450545467450059059869618211361469505108\n", "43\n7404899846883344886153727489084158470112581\n", "100\n0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008\n", "8\n12345678\n", "88\n2694079127792970410465292300936220976260790323517221561516591792566791677970332966660472\n", "21\n582586788289484878588\n", "33\n270375004567749549929235905225024\n", "50\n88000000000000000000000000000000000000000000000000\n", "33\n429980628264468835720540136177288\n", "27\n888000000000000000000000000\n", "10\n8000000000\n", "74\n70988894874867688968816582886488688881063425288316858438189808828755218508\n", "22\n6188156585823394680191\n", "81\n808888883488887888888808888888888888188888888388888888888888868688888488888882888\n", "57\n888888888888888888888888888888888888888888888888888888888\n", "100\n6451941807833681891890004306065158148809856572066617888008875119881621810329816763604830895480467878\n", "83\n88584458884288808888588388818938838468960248387898182887888867888888888886088895788\n", "11\n81234567090\n", "21\n880000000000000000000\n", "94\n8188948828818938226378510887848897889883818858778688882933888883888898198978868888808082461388\n", "52\n8878588869084488848898838898788838337877898817818888\n", "61\n8880888836888988888988888887388888888888868898887888818888888\n", "71\n88888888888888888888888188888805848888788088888883888883187888838888888\n", "95\n29488352815808808845913584782288724288898869488882098428839370889284838688458247785878848884289\n", "73\n2185806538483837898808836883483888818818988881880688028788888081888907898\n", "80\n88888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "55\n3982037603326093160114589190899881252765957832414122484\n", "100\n8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\n", "51\n1732111733638718702525811518175029394157760329139501\n", "55\n8150965228922987149322123425550549439018369681986057802\n", "72\n129108839650139854381903715683735947815379560715643428841035623040980032\n", "42\n1251996236006506309908626867460855811743437\n", "11\n78451611424\n", "31\n1288033400433082469939233589875\n", "77\n11111111111111111111111111110111111111111111111111111111111111111111111111111\n", "100\n6152069453350735030379611937645928787504993143655436498747601445943408903686298029084639414463403044\n", "91\n14936165072891114728916862658660934186358455115509481550778215813586122858153579186424029047\n", "99\n274084708428239737964144281827339813543219110156398212401158259206614326520025226572837805871014585\n", "65\n48741672913800855829009396895109319701475498378204701259174825079\n", "54\n779678408554409873811691913824373072271022281181199372\n", "100\n2956058251342921002154580504550305512343357719751238174127440647858171411479019640719389442193156761\n", "75\n1447209574891881128506764534477602010865884193215132888674271629390187643471\n", "21\n144372480849939667628\n", "62\n22219613982136747210935631389171649693997034283345662337583626\n", "30\n1753916125842151020270252344941\n", "64\n11582262715289018472878260813237715750398740538192284144993914364\n", "50\n176486247346285355078927403393181612062909344472557\n", "20\n91475329980766165627\n", "32\n19421253273631271902830546309853\n", "82\n7130439677311429054289691926669678715559951971255528089422170252214949673055037409\n", "87\n162583935074903283877678799324942261343776405281956667200663049919992379727457618445822\n", "85\n5179672314445498518747825535464653999958180121132851369872452192607293658801721323112\n", "100\n9056860173107534527953825197265296206177542053400053495648579654157105028804543604477636859834254169\n", "1\n1\n", "93\n142900738143682625540105342312253998971541513968430294618654527208656244186427714456429260061\n", "40\n5893664850088420104653125672989780401302\n", "33\n1316344704121056356767252590078035\n", "21\n961247912193573032091\n", "98\n49633593424238946228753574785033663393046515774919065229285836778263762289889151310882662050295958\n", "90\n730563418212452051964132091144698723276121264664193850618023916261543013128815335399938850\n", "22\n7062633451897974105718\n", "96\n961606338203745446796386398079921610824760993214546398685366784604568762326307249029204455750851\n", "1\n2\n", "100\n7175584485805705849693168885514278862585249734475140923711025638113565719364706001732933879282593903\n", "86\n89039327901659721416677561947986258951074654231236865933796800700895217312937370088565\n", "92\n13903087491287793799250985459288313710990837230413759979322281000113896197749900430556616452\n", "76\n5668848880083489060516181669185910162345821775435654230881288559909881276359\n", "32\n58450846655060080321140700557862\n", "70\n16574756577915966791279923539175441020736780209276978053521928356127012\n", "11\n113055057882\n", "21\n268581310685218650707\n", "22\n17634833004338166206452\n", "11\n145852211224\n", "41\n156430801927200855536123837894662214568721\n", "63\n573970989884638574001047539444219592287349724845896428516061930\n", "100\n1649954454354216348324856353744769591239957512599507743765021441866612320593824942841904141584444809\n", "100\n10073026040057460848727605087211482331696312132261702754626166388448133087167204984955299978572844873\n", "53\n10294950976088816073199215671673167174963164469332544\n", "60\n903744304501293516369258888423725616678289531242891710261181\n", "84\n248058851050244586329972244431845068342053230180314142152399592177294389690811412469\n", "43\n1139522786373859748629536978350302283047435\n", "21\n414764769360229758359\n", "50\n125006241747367172352961887620449940392294290156400\n", "33\n163445991198719783945688442744574\n", "27\n1771475345807520480504293951\n", "74\n36141517601805443470215839078489508863753596872271855476653668390338703335\n", "22\n6162495896368099518135\n", "81\n1363025613301211201344873793522274412138701392236333959084281266030086492586969946\n", "57\n1423705310783370356206488007848026002555725247788497695627\n", "100\n8214196852752695233729514144265209784838859240743133895909669295408086624114628470690490149346858149\n", "11\n125693053523\n", "21\n308846580116646657569\n", "94\n7747830900414725615555168784062745495617871594159096430181393382508562672892413314594899237874\n", "52\n15654026030811325908652336362901586634418944356707873\n", "61\n3124080573365283337934382711688970811847579177395736805511317\n", "95\n41233047758106206206178493651979098498928879946838810418979522774647327191027440365238678414753\n", "73\n4184646398440799539343302069138501059187195143871098078245424570574650630\n", "80\n70052317105276311821557953815064235609254227147552660921877560719279678214601763\n", "55\n2532584617276433831959785690851391005271119317728379073\n", "100\n12214470388509637187316171407185732399094381485438987303313809772379863936872280956215437122989955784\n", "11\n50641445791\n", "51\n1645695007619178112182600011052173832799865107349261\n", "55\n8052132475340067086462704381340546682468514641256540302\n", "65\n80507303857224037529289924361631148371584546228214411186937338609\n", "42\n1400161523759972055334925227721345988082774\n", "75\n381633323259241978825160604051651800305930639598198353611274713769732694803\n", "11\n85999264342\n", "21\n158411602392309813153\n", "77\n11111111111111111111111111110111111111111111111111111111111111110111111111111\n" ], "output": [ "2\n", "1\n", "0\n", "4\n", "0\n", "6\n", "5\n", "4\n", "1\n", "9\n", "3\n", "6\n", "1\n", "2\n", "1\n", "5\n", "0\n", "2\n", "5\n", "0\n", "8\n", "2\n", "4\n", "1\n", "2\n", "7\n", "8\n", "7\n", "7\n", "9\n", "1\n", "0\n", "8\n", "0\n", "3\n", "3\n", "1\n", "8\n", "8\n", "0\n", "0\n", "8\n", "0\n", "9\n", "1\n", "7\n", "8\n", "6\n", "2\n", "6\n", "1\n", "1\n", "0\n", "2\n", "1\n", "3\n", "0\n", "9\n", "5\n", "2\n", "5\n", "9\n", "1\n", "9\n", "4\n", "5\n", "9\n", "0\n", "7\n", "2\n", "9\n", "3\n", "1\n", "0\n", "0\n", "1\n", "0\n", "2\n", "3\n", "2\n", "0\n", "6\n", "2\n", "7\n", "5\n", "9\n", "7\n", "1\n", "1\n", "8\n", "4\n", "5\n", "6\n", "8\n", "6\n", "7\n", "5\n", "9\n", "4\n", "5\n", "6\n", "3\n", "1\n", "2\n", "0\n", "7\n", "8\n", "9\n", "5\n", "4\n", "6\n", "6\n", "1\n", "4\n", "1\n", "5\n", "4\n", "1\n", "2\n", "4\n", "7\n", "7\n", "7\n", "0\n", "7\n", "3\n", "1\n", "0\n", "8\n", "8\n", "2\n", "8\n", "0\n", "9\n", "7\n", "8\n", "6\n", "2\n", "3\n", "1\n", "1\n", "2\n", "1\n", "3\n", "5\n", "7\n", "9\n", "3\n", "5\n", "7\n", "3\n", "1\n", "2\n", "3\n", "2\n", "6\n", "2\n", "6\n", "5\n", "9\n", "0\n", "1\n", "8\n", "4\n", "5\n", "8\n", "6\n", "4\n", "5\n", "9\n", "0\n", "4\n", "5\n", "5\n", "3\n", "6\n", "1\n", "1\n", "0\n" ] }
2CODEFORCES
Below is a problem description that describes the problem. Write code in Python that appropriately solves the problem. ### Description: Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct. Input The first line contains an integer n β€” the number of cards with digits that you have (1 ≀ n ≀ 100). The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces. Output If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0. Examples Input 11 00000000008 Output 1 Input 22 0011223344556677889988 Output 2 Input 11 31415926535 Output 0 Note In the first example, one phone number, "8000000000", can be made from these cards. In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789". In the third example you can't make any phone number from the given cards. ### Input: 22 0011223344556677889988 ### Output: 2 ### Input: 11 00000000008 ### Output: 1 ### Code: n = int(input()) s = input() k = s.count("8") l = n - k if k <= l//10: print(k) else: while k > l//10: k -= 1 l += 1 print(min(k, l//10))
1101_A. Minimum Integer_19
You are given q queries in the following form: Given three integers l_i, r_i and d_i, find minimum positive integer x_i such that it is divisible by d_i and it does not belong to the segment [l_i, r_i]. Can you answer all the queries? Recall that a number x belongs to segment [l, r] if l ≀ x ≀ r. Input The first line contains one integer q (1 ≀ q ≀ 500) β€” the number of queries. Then q lines follow, each containing a query given in the format l_i r_i d_i (1 ≀ l_i ≀ r_i ≀ 10^9, 1 ≀ d_i ≀ 10^9). l_i, r_i and d_i are integers. Output For each query print one integer: the answer to this query. Example Input 5 2 4 2 5 10 4 3 10 1 1 2 3 4 6 5 Output 6 4 1 3 10
n = int(input()) A = [] for i in range(n): A = A+[input().split()] for a in A: if int(a[2]) < int(a[0]) or int(a[2]) > int(a[1]): print(a[2]) else: print(int(a[2])*(int(a[1])//int(a[2])+1))
{ "input": [ "5\n2 4 2\n5 10 4\n3 10 1\n1 2 3\n4 6 5\n", "20\n1 1000000000 2\n1 1000000000 2\n1 1000000000 2\n1 1000000000 2\n1 1000000000 2\n1 1000000000 2\n1 1000000000 2\n1 1000000000 2\n1 1000000000 2\n1 1000000000 2\n1 1000000000 2\n1 1000000000 2\n1 1000000000 2\n1 1000000000 2\n1 1000000000 2\n1 1000000000 2\n1 1000000000 2\n1 1000000000 2\n1 1000000000 2\n1 1000000000 2\n", "1\n78 79 79\n", "1\n6 6 6\n", "20\n1 1 1\n1 999999999 1\n1 999999999 1\n1 999999999 1\n1 999999999 1\n1 999999999 1\n1 999999999 1\n1 999999999 1\n1 999999999 1\n1 999999999 1\n1 999999999 1\n1 999999999 1\n1 999999999 1\n1 999999999 1\n1 999999999 1\n1 999999999 1\n1 999999999 1\n1 999999999 1\n1 999999999 1\n1 999999999 1\n", "1\n78 1000 1\n", "1\n77 10000 1\n", "20\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n", "10\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n", "1\n78 80 1\n", "20\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n", "1\n1 1 123456789\n", "1\n80 100 1\n", "5\n1000000000 1000000000 1\n1000000000 1000000000 1\n1000000000 1000000000 1\n1000000000 1000000000 1\n1000000000 1000000000 1\n", "1\n78 10000 1\n", "1\n79 80 100\n", "5\n1 1000000000 1\n1 999999999 1\n1 999999998 1\n1 999999997 1\n1 999999996 1\n", "5\n1 1000000000 1\n1 1000000000 1000000000\n2 1000000000 1\n1 999999999 1000000000\n5 6 5\n", "30\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n", "1\n78 89 34\n", "1\n1 1 1\n", "1\n1 3 2\n", "10\n1 999999998 1\n1 999999998 1\n1 999999998 1\n1 999999998 1\n1 999999998 1\n1 999999998 1\n1 999999998 1\n1 999999998 1\n1 999999998 1\n1 999999998 1\n", "4\n1 999999999 1\n1 999999998 1\n1 999999997 1\n1 999999996 1\n", "5\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n", "2\n1 1 2\n1 1 2\n", "1\n80 100 80\n", "25\n1 1000000000 1\n1 1000000000 1000000000\n2 1000000000 1\n1 999999999 1000000000\n5 6 5\n1 1000000000 1\n1 1000000000 1000000000\n2 1000000000 1\n1 999999999 1000000000\n5 6 5\n1 1000000000 1\n1 1000000000 1000000000\n2 1000000000 1\n1 999999999 1000000000\n5 6 5\n1 1000000000 1\n1 1000000000 1000000000\n2 1000000000 1\n1 999999999 1000000000\n5 6 5\n1 1000000000 1\n1 1000000000 1000000000\n2 1000000000 1\n1 999999999 1000000000\n5 6 5\n", "30\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n", "16\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n", "1\n1 1000000000 6\n", "1\n5 5 5\n", "1\n2 5 6\n", "8\n1 999999998 1\n1 999999997 1\n1 999999996 1\n1 999999995 1\n1 999999994 1\n1 999999993 1\n1 999999992 1\n1 999999991 1\n", "5\n80 100 10\n5 10 4\n3 10 1\n1 2 3\n4 6 5\n", "1\n1 1000000000 1017\n", "1\n1 1000000000 2\n", "1\n78 1 79\n", "1\n2 6 6\n", "20\n1 1 1\n1 999999999 1\n1 999999999 1\n1 999999999 1\n1 999999999 1\n1 999999999 1\n1 999999999 1\n1 999999999 1\n1 999999999 1\n1 832136582 1\n1 999999999 1\n1 999999999 1\n1 999999999 1\n1 999999999 1\n1 999999999 1\n1 999999999 1\n1 999999999 1\n1 999999999 1\n1 999999999 1\n1 999999999 1\n", "1\n78 1100 1\n", "1\n77 10000 2\n", "20\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000100000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n", "10\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000010 1\n1 1000000000 1\n", "20\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n1 1000000010 3\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n", "1\n0 1 123456789\n", "5\n1000000000 1000000000 1\n1000000000 1000000000 1\n1000000000 1100000000 1\n1000000000 1000000000 1\n1000000000 1000000000 1\n", "1\n79 144 100\n", "5\n1 1000000000 1\n1 999999999 1\n1 999999998 1\n2 999999997 1\n1 999999996 1\n", "5\n1 1000000000 1\n1 1000000000 1000000000\n2 1000000000 1\n1 999999999 1000000000\n5 4 5\n", "30\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 749549584 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n", "1\n69 89 34\n", "1\n0 3 2\n", "4\n1 999999999 1\n1 999999998 2\n1 999999997 1\n1 999999996 1\n", "5\n1 1000000000 1\n2 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n", "2\n1 1 4\n1 1 2\n", "1\n80 000 80\n", "25\n1 1000000000 1\n1 1000000000 1000000000\n2 1000000000 1\n1 999999999 1000000000\n5 6 5\n1 1000000000 1\n1 1000000000 1000000000\n2 1000000000 1\n1 999999999 1000000000\n5 6 5\n1 1000000000 1\n1 1000000000 1000000000\n2 1000000000 1\n1 999999999 1000000000\n5 6 5\n1 1000000000 1\n1 1000000000 1000000000\n2 1000000000 1\n1 999999999 1000000000\n5 6 5\n1 1000000000 1\n1 1000000000 1000000000\n2 1000000000 1\n1 639799271 1000000000\n5 6 5\n", "30\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 2\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n", "16\n1 1000000000 1\n1 1000000000 1\n1 1000100000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n", "1\n1 1000010000 2\n", "1\n5 5 6\n", "8\n1 999999998 1\n1 999999997 1\n1 999999996 1\n1 999999995 1\n1 999999994 1\n1 999999993 1\n1 999999992 2\n1 999999991 1\n", "5\n80 101 10\n5 10 4\n3 10 1\n1 2 3\n4 6 5\n", "1\n1 1000000010 1017\n", "1\n1 1000000000 4\n", "5\n2 4 2\n5 10 4\n3 10 1\n2 2 3\n4 6 5\n", "1\n78 1 125\n", "20\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n2 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000100000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n", "1\n79 263 100\n", "5\n1 1100000000 1\n1 999999999 1\n1 999999998 1\n2 999999997 1\n1 999999996 1\n", "5\n2 1000000000 1\n1 1000000000 1000000000\n2 1000000000 1\n1 999999999 1000000000\n5 4 5\n", "1\n69 89 56\n", "4\n1 474817329 1\n1 999999998 2\n1 999999997 1\n1 999999996 1\n", "1\n80 000 109\n", "25\n1 1000000000 1\n1 0000000000 1000000000\n2 1000000000 1\n1 999999999 1000000000\n5 6 5\n1 1000000000 1\n1 1000000000 1000000000\n2 1000000000 1\n1 999999999 1000000000\n5 6 5\n1 1000000000 1\n1 1000000000 1000000000\n2 1000000000 1\n1 999999999 1000000000\n5 6 5\n1 1000000000 1\n1 1000000000 1000000000\n2 1000000000 1\n1 999999999 1000000000\n5 6 5\n1 1000000000 1\n1 1000000000 1000000000\n2 1000000000 1\n1 639799271 1000000000\n5 6 5\n", "16\n2 1000000000 1\n1 1000000000 1\n1 1000100000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n", "1\n5 5 8\n", "8\n1 999999998 1\n1 999999997 1\n1 402421533 1\n1 999999995 1\n1 999999994 1\n1 999999993 1\n1 999999992 2\n1 999999991 1\n", "1\n1 1000000010 1391\n", "1\n1 1000001000 4\n", "1\n0 2 227752323\n", "1\n79 306 100\n", "5\n2 1100000000 1\n1 999999999 1\n1 999999998 1\n2 999999997 1\n1 999999996 1\n", "30\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 1467985723 2\n1 999999999 2\n1 749549584 2\n2 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n", "1\n6 89 56\n", "1\n1 2 3\n", "4\n1 474817329 1\n1 999999998 2\n1 999999997 1\n2 999999996 1\n", "16\n2 1000000000 1\n1 1000000000 1\n1 1000100000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1000000000 1\n1 1001000000 1\n1 1000000000 1\n", "5\n62 101 10\n5 10 4\n1 10 1\n1 2 3\n4 6 5\n", "1\n1 1000000000 3\n", "5\n1100000000 1000000000 1\n1000000000 1000000000 1\n1000000000 1100000000 2\n1000000000 1000000001 1\n1000000000 1000000000 1\n", "1\n110 306 100\n", "5\n1 1100000000 1\n1 999999999 1\n1 999999998 1\n2 999999997 1\n1 440567035 1\n", "5\n2 1000000000 1\n1 1000000000 1001000000\n2 1000000000 1\n2 999999999 1000000000\n5 4 5\n", "4\n1 474817329 1\n1 999999998 1\n1 999999997 1\n2 999999996 1\n", "1\n4 4 7\n", "5\n62 101 10\n5 10 4\n1 10 2\n1 2 3\n4 6 5\n", "1\n0 1000000010 2440\n", "1\n1 1000000000 1\n", "1\n2 6 11\n", "1\n78 119 1\n", "1\n80 100 2\n", "1\n145 10000 1\n", "1\n1 1 2\n", "1\n2 4 6\n", "1\n2 10 6\n", "20\n1 1 1\n1 999999999 1\n1 999999999 1\n1 999999999 1\n1 999999999 1\n1 999999999 1\n1 999999999 2\n1 999999999 1\n1 999999999 1\n1 832136582 1\n1 999999999 1\n1 999999999 1\n1 999999999 1\n1 999999999 1\n1 999999999 1\n1 999999999 1\n1 999999999 1\n1 999999999 1\n1 999999999 1\n1 999999999 1\n", "1\n142 1100 1\n", "1\n60 10000 2\n", "1\n78 92 1\n", "20\n1 1000000000 3\n1 1000000000 3\n1 1000000000 6\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n1 1000000010 3\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n", "1\n0 2 123456789\n", "1\n67 100 2\n", "5\n1100000000 1000000000 1\n1000000000 1000000000 1\n1000000000 1100000000 1\n1000000000 1000000000 1\n1000000000 1000000000 1\n", "1\n145 10001 1\n", "30\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 749549584 2\n2 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n1 999999999 2\n", "1\n1 0 2\n", "1\n1 3 3\n", "1\n2 1000010000 2\n", "1\n2 3 6\n", "5\n62 101 10\n5 10 4\n3 10 1\n1 2 3\n4 6 5\n", "1\n2 10 4\n", "1\n142 1100 2\n", "1\n60 10001 2\n", "1\n78 132 1\n", "20\n1 1000000000 3\n1 1000000000 3\n1 1000000000 6\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n1 1000000010 3\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n1 1000000000 3\n2 1000000000 3\n1 1000000000 3\n1 1000000000 3\n", "1\n67 100 4\n", "5\n1100000000 1000000000 1\n1000000000 1000000000 1\n1000000000 1100000000 1\n1000000000 1000000001 1\n1000000000 1000000000 1\n", "1\n181 10001 1\n", "5\n2 1000000000 1\n1 1000000000 1000000000\n2 1000000000 1\n2 999999999 1000000000\n5 4 5\n", "1\n0 0 2\n", "1\n80 100 109\n", "25\n1 1000000000 1\n1 0000000000 1000000000\n2 1000000000 1\n1 999999999 1000000000\n5 6 5\n1 1000000000 1\n1 1000000000 1000000000\n2 1000000000 1\n1 999999999 1000000000\n5 6 5\n1 1000000000 1\n1 1000010000 1000000000\n2 1000000000 1\n1 999999999 1000000000\n5 6 5\n1 1000000000 1\n1 1000000000 1000000000\n2 1000000000 1\n1 999999999 1000000000\n5 6 5\n1 1000000000 1\n1 1000000000 1000000000\n2 1000000000 1\n1 639799271 1000000000\n5 6 5\n", "1\n5 4 8\n", "1\n4 4 6\n", "1\n0 1000000010 1391\n" ], "output": [ "6\n4\n1\n3\n10\n", "1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n", "158\n", "12\n", "2\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n", "1\n", "1\n", "1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n", "1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n", "1\n", "1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n", "123456789\n", "1\n", "1\n1\n1\n1\n1\n", "1\n", "100\n", "1000000001\n1000000000\n999999999\n999999998\n999999997\n", "1000000001\n2000000000\n1\n1000000000\n10\n", "1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n", "34\n", "2\n", "4\n", "999999999\n999999999\n999999999\n999999999\n999999999\n999999999\n999999999\n999999999\n999999999\n999999999\n", "1000000000\n999999999\n999999998\n999999997\n", "1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n", "2\n2\n", "160\n", "1000000001\n2000000000\n1\n1000000000\n10\n1000000001\n2000000000\n1\n1000000000\n10\n1000000001\n2000000000\n1\n1000000000\n10\n1000000001\n2000000000\n1\n1000000000\n10\n1000000001\n2000000000\n1\n1000000000\n10\n", "1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n", "1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n", "1000000002\n", "10\n", "6\n", "999999999\n999999998\n999999997\n999999996\n999999995\n999999994\n999999993\n999999992\n", "10\n4\n1\n3\n10\n", "1000000845\n", "1000000002\n", "79\n", "12\n", "2\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n832136583\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n", "1\n", "2\n", "1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000100001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n", "1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000011\n1000000001\n", "1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000011\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n", "123456789\n", "1\n1\n1\n1\n1\n", "200\n", "1000000001\n1000000000\n999999999\n1\n999999997\n", "1000000001\n2000000000\n1\n1000000000\n5\n", "1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n749549586\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n", "34\n", "4\n", "1000000000\n1000000000\n999999998\n999999997\n", "1000000001\n1\n1000000001\n1000000001\n1000000001\n", "4\n2\n", "80\n", "1000000001\n2000000000\n1\n1000000000\n10\n1000000001\n2000000000\n1\n1000000000\n10\n1000000001\n2000000000\n1\n1000000000\n10\n1000000001\n2000000000\n1\n1000000000\n10\n1000000001\n2000000000\n1\n1000000000\n10\n", "1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000002\n1000000001\n1000000001\n1000000001\n1000000001\n", "1000000001\n1000000001\n1000100001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n", "1000010002\n", "6\n", "999999999\n999999998\n999999997\n999999996\n999999995\n999999994\n999999994\n999999992\n", "10\n4\n1\n3\n10\n", "1000000845\n", "1000000004\n", "6\n4\n1\n3\n10\n", "125\n", "1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000100001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n", "300\n", "1100000001\n1000000000\n999999999\n1\n999999997\n", "1\n2000000000\n1\n1000000000\n5\n", "56\n", "474817330\n1000000000\n999999998\n999999997\n", "109\n", "1000000001\n1000000000\n1\n1000000000\n10\n1000000001\n2000000000\n1\n1000000000\n10\n1000000001\n2000000000\n1\n1000000000\n10\n1000000001\n2000000000\n1\n1000000000\n10\n1000000001\n2000000000\n1\n1000000000\n10\n", "1\n1000000001\n1000100001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n", "8\n", "999999999\n999999998\n402421534\n999999996\n999999995\n999999994\n999999994\n999999992\n", "1000001028\n", "1000001004\n", "227752323\n", "400\n", "1\n1000000000\n999999999\n1\n999999997\n", "1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1467985724\n1000000000\n749549586\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n", "112\n", "3\n", "474817330\n1000000000\n999999998\n1\n", "1\n1000000001\n1000100001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1001000001\n1000000001\n", "10\n4\n11\n3\n10\n", "1000000002\n", "1\n1\n2\n1\n1\n", "100\n", "1100000001\n1000000000\n999999999\n1\n440567036\n", "1\n1001000000\n1\n1000000000\n5\n", "474817330\n999999999\n999999998\n1\n", "7\n", "10\n4\n12\n3\n10\n", "1000002280\n", "1000000001\n", "11\n", "1\n", "2\n", "1\n", "2\n", "6\n", "12\n", "2\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n832136583\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n", "1\n", "2\n", "1\n", "1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000011\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n", "123456789\n", "2\n", "1\n1\n1\n1\n1\n", "1\n", "1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n749549586\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n", "2\n", "6\n", "1000010002\n", "6\n", "10\n4\n1\n3\n10\n", "12\n", "2\n", "2\n", "1\n", "1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000011\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n1000000002\n", "4\n", "1\n1\n1\n1\n1\n", "1\n", "1\n2000000000\n1\n1000000000\n5\n", "2\n", "109\n", "1000000001\n1000000000\n1\n1000000000\n10\n1000000001\n2000000000\n1\n1000000000\n10\n1000000001\n2000000000\n1\n1000000000\n10\n1000000001\n2000000000\n1\n1000000000\n10\n1000000001\n2000000000\n1\n1000000000\n10\n", "8\n", "6\n", "1000001028\n" ] }
2CODEFORCES
Below is a problem description that describes the problem. Write code in Python that appropriately solves the problem. ### Description: You are given q queries in the following form: Given three integers l_i, r_i and d_i, find minimum positive integer x_i such that it is divisible by d_i and it does not belong to the segment [l_i, r_i]. Can you answer all the queries? Recall that a number x belongs to segment [l, r] if l ≀ x ≀ r. Input The first line contains one integer q (1 ≀ q ≀ 500) β€” the number of queries. Then q lines follow, each containing a query given in the format l_i r_i d_i (1 ≀ l_i ≀ r_i ≀ 10^9, 1 ≀ d_i ≀ 10^9). l_i, r_i and d_i are integers. Output For each query print one integer: the answer to this query. Example Input 5 2 4 2 5 10 4 3 10 1 1 2 3 4 6 5 Output 6 4 1 3 10 ### Input: 5 2 4 2 5 10 4 3 10 1 1 2 3 4 6 5 ### Output: 6 4 1 3 10 ### Input: 20 1 1000000000 2 1 1000000000 2 1 1000000000 2 1 1000000000 2 1 1000000000 2 1 1000000000 2 1 1000000000 2 1 1000000000 2 1 1000000000 2 1 1000000000 2 1 1000000000 2 1 1000000000 2 1 1000000000 2 1 1000000000 2 1 1000000000 2 1 1000000000 2 1 1000000000 2 1 1000000000 2 1 1000000000 2 1 1000000000 2 ### Output: 1000000002 1000000002 1000000002 1000000002 1000000002 1000000002 1000000002 1000000002 1000000002 1000000002 1000000002 1000000002 1000000002 1000000002 1000000002 1000000002 1000000002 1000000002 1000000002 1000000002 ### Code: n = int(input()) A = [] for i in range(n): A = A+[input().split()] for a in A: if int(a[2]) < int(a[0]) or int(a[2]) > int(a[1]): print(a[2]) else: print(int(a[2])*(int(a[1])//int(a[2])+1))
1189_D1. Add on a Tree_27
Note that this is the first problem of the two similar problems. You can hack this problem only if you solve both problems. You are given a tree with n nodes. In the beginning, 0 is written on all edges. In one operation, you can choose any 2 distinct leaves u, v and any real number x and add x to values written on all edges on the simple path between u and v. For example, on the picture below you can see the result of applying two operations to the graph: adding 2 on the path from 7 to 6, and then adding -0.5 on the path from 4 to 5. <image> Is it true that for any configuration of real numbers written on edges, we can achieve it with a finite number of operations? Leaf is a node of a tree of degree 1. Simple path is a path that doesn't contain any node twice. Input The first line contains a single integer n (2 ≀ n ≀ 10^5) β€” the number of nodes. Each of the next n-1 lines contains two integers u and v (1 ≀ u, v ≀ n, u β‰  v), meaning that there is an edge between nodes u and v. It is guaranteed that these edges form a tree. Output If there is a configuration of real numbers written on edges of the tree that we can't achieve by performing the operations, output "NO". Otherwise, output "YES". You can print each letter in any case (upper or lower). Examples Input 2 1 2 Output YES Input 3 1 2 2 3 Output NO Input 5 1 2 1 3 1 4 2 5 Output NO Input 6 1 2 1 3 1 4 2 5 2 6 Output YES Note In the first example, we can add any real x to the value written on the only edge (1, 2). <image> In the second example, one of configurations that we can't reach is 0 written on (1, 2) and 1 written on (2, 3). <image> Below you can see graphs from examples 3, 4: <image> <image>
m = int(input()) l = [0 for _ in range(m + 1)] for _ in range(m - 1): a,b = map(int, input().split()) l[a] += 1 l[b] += 1 if 2 in l: print("NO") else: print("YES")
{ "input": [ "2\n1 2\n", "3\n1 2\n2 3\n", "5\n1 2\n1 3\n1 4\n2 5\n", "6\n1 2\n1 3\n1 4\n2 5\n2 6\n", "50\n16 4\n17 9\n31 19\n22 10\n8 1\n40 30\n3 31\n20 29\n47 27\n22 25\n32 34\n12 15\n40 32\n10 33\n47 12\n6 24\n46 41\n14 23\n12 35\n31 42\n46 28\n31 20\n46 37\n1 39\n29 49\n37 47\n40 6\n42 36\n47 2\n24 46\n2 13\n8 45\n41 3\n32 17\n4 7\n47 26\n28 8\n41 50\n34 44\n33 21\n25 5\n16 40\n3 14\n8 18\n28 11\n32 22\n2 38\n3 48\n44 43\n", "10\n8 1\n1 2\n8 9\n8 5\n1 3\n1 10\n1 6\n1 7\n8 4\n", "5\n5 1\n5 4\n4 3\n1 2\n", "7\n1 2\n2 3\n1 4\n1 5\n3 6\n3 7\n", "3\n1 3\n2 3\n", "60\n26 6\n59 30\n31 12\n31 3\n38 23\n59 29\n53 9\n38 56\n53 54\n29 21\n17 55\n59 38\n26 16\n24 59\n24 25\n17 35\n24 41\n30 15\n31 27\n8 44\n26 5\n26 48\n8 32\n53 17\n3 34\n3 51\n30 28\n47 10\n53 60\n36 42\n24 53\n59 22\n53 40\n26 52\n36 4\n59 8\n29 37\n36 20\n17 47\n53 18\n3 50\n30 2\n17 7\n8 58\n59 1\n31 11\n24 26\n24 43\n53 57\n59 45\n47 13\n26 46\n17 33\n30 31\n26 39\n26 19\n24 36\n8 49\n38 14\n", "7\n1 2\n2 3\n3 4\n3 5\n1 6\n1 7\n", "20\n19 16\n19 18\n20 7\n9 4\n6 17\n14 2\n9 15\n2 13\n5 11\n19 12\n12 20\n16 9\n11 8\n19 5\n3 1\n19 14\n5 3\n12 10\n19 6\n", "7\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7\n", "10\n9 5\n7 1\n9 10\n7 2\n5 4\n9 6\n2 9\n10 8\n1 3\n", "4\n2 4\n2 3\n2 1\n", "4\n1 4\n3 2\n1 3\n", "3\n1 2\n1 3\n", "5\n1 2\n1 5\n1 3\n1 4\n", "20\n14 9\n12 13\n10 15\n2 1\n20 19\n16 6\n16 3\n17 14\n3 5\n2 11\n3 10\n15 8\n14 2\n6 4\n3 20\n5 18\n1 7\n1 16\n4 12\n", "20\n7 5\n14 13\n17 6\n3 8\n16 12\n18 9\n3 18\n14 1\n17 3\n15 2\n17 4\n9 11\n2 7\n15 17\n3 20\n16 10\n17 14\n2 16\n1 19\n", "8\n1 2\n2 3\n3 4\n1 7\n1 8\n4 5\n4 6\n", "5\n5 1\n5 2\n5 3\n5 4\n", "50\n49 6\n43 7\n1 27\n19 35\n15 37\n16 12\n19 21\n16 28\n49 9\n48 39\n13 1\n2 48\n9 50\n44 3\n41 32\n48 31\n49 33\n6 11\n13 20\n49 22\n13 41\n48 29\n13 46\n15 47\n34 2\n49 13\n48 14\n34 24\n16 36\n13 40\n49 34\n49 17\n43 25\n11 23\n10 15\n19 26\n34 44\n16 42\n19 18\n46 8\n29 38\n1 45\n12 43\n13 16\n46 30\n15 5\n49 10\n11 19\n32 4\n", "20\n13 1\n18 2\n3 7\n18 5\n20 16\n3 12\n18 9\n3 10\n18 11\n13 6\n3 18\n20 15\n20 17\n3 13\n3 4\n13 14\n3 20\n18 8\n3 19\n", "10\n8 2\n5 6\n1 8\n2 9\n1 4\n8 10\n10 5\n2 7\n2 3\n", "50\n16 4\n17 9\n31 19\n3 10\n8 1\n40 30\n3 31\n20 29\n47 27\n22 25\n32 34\n12 15\n40 32\n10 33\n47 12\n6 24\n46 41\n14 23\n12 35\n31 42\n46 28\n31 20\n46 37\n1 39\n29 49\n37 47\n40 6\n42 36\n47 2\n24 46\n2 13\n8 45\n41 3\n32 17\n4 7\n47 26\n28 8\n41 50\n34 44\n33 21\n25 5\n16 40\n3 14\n8 18\n28 11\n32 22\n2 38\n3 48\n44 43\n", "7\n1 2\n1 3\n2 4\n2 5\n1 6\n2 7\n", "5\n5 1\n5 4\n4 3\n2 2\n", "60\n26 6\n59 30\n31 12\n31 3\n38 23\n59 29\n53 9\n38 56\n53 54\n29 21\n17 55\n59 38\n26 16\n24 59\n24 25\n17 35\n24 41\n30 15\n31 27\n8 44\n26 5\n26 48\n8 32\n53 17\n3 34\n3 51\n20 28\n47 10\n53 60\n36 42\n24 53\n59 22\n53 40\n26 52\n36 4\n59 8\n29 37\n36 20\n17 47\n53 18\n3 50\n30 2\n17 7\n8 58\n59 1\n31 11\n24 26\n24 43\n53 57\n59 45\n47 13\n26 46\n17 33\n30 31\n26 39\n26 19\n24 36\n8 49\n38 14\n", "7\n1 2\n2 4\n3 4\n3 5\n1 6\n1 7\n", "7\n1 2\n1 3\n2 4\n2 5\n1 6\n3 7\n", "10\n9 5\n4 1\n9 10\n7 2\n5 4\n9 6\n2 9\n10 8\n1 3\n", "4\n3 4\n2 3\n2 1\n", "6\n1 2\n1 3\n2 4\n2 5\n2 6\n", "60\n26 6\n59 30\n31 12\n31 3\n38 23\n59 29\n53 9\n38 56\n53 54\n29 21\n17 55\n59 38\n26 16\n24 59\n24 25\n17 35\n24 41\n30 15\n31 27\n8 44\n26 5\n26 48\n8 32\n53 17\n3 34\n3 51\n20 28\n47 10\n53 60\n36 42\n24 53\n59 22\n53 40\n26 52\n36 4\n59 8\n29 37\n36 20\n17 47\n53 18\n3 50\n30 2\n17 7\n8 58\n59 1\n31 11\n24 26\n24 43\n53 57\n59 45\n47 13\n49 46\n17 33\n30 31\n26 39\n26 19\n24 36\n8 49\n38 14\n", "10\n9 5\n4 1\n9 10\n7 1\n5 4\n9 6\n2 9\n10 8\n1 3\n", "6\n1 2\n1 3\n2 4\n4 5\n2 6\n", "60\n26 6\n59 30\n31 12\n31 3\n38 23\n59 29\n53 9\n59 56\n53 54\n29 21\n17 55\n59 38\n26 16\n24 59\n24 25\n17 35\n24 41\n30 15\n31 27\n8 44\n26 5\n26 48\n8 32\n53 17\n3 34\n3 51\n20 28\n47 10\n53 60\n36 42\n24 53\n59 22\n53 40\n26 52\n36 4\n59 8\n29 37\n36 20\n17 47\n53 18\n3 50\n30 2\n17 7\n8 58\n59 1\n31 11\n24 26\n24 43\n53 57\n59 45\n47 13\n49 46\n17 33\n30 31\n26 39\n26 19\n24 36\n8 49\n38 14\n", "7\n1 2\n1 3\n2 4\n3 5\n1 6\n2 7\n", "6\n1 2\n1 3\n2 4\n4 5\n1 6\n", "60\n26 6\n59 30\n31 12\n32 3\n38 23\n59 29\n53 9\n59 56\n53 54\n29 21\n17 55\n59 38\n26 16\n24 59\n24 25\n17 35\n24 41\n30 15\n31 27\n8 44\n26 5\n26 48\n8 32\n53 17\n3 34\n3 51\n20 28\n47 10\n53 60\n36 42\n24 53\n59 22\n53 40\n26 52\n36 4\n59 8\n29 37\n36 20\n17 47\n53 18\n3 50\n30 2\n17 7\n8 58\n59 1\n31 11\n24 26\n24 43\n53 57\n59 45\n47 13\n49 46\n17 33\n30 31\n26 39\n26 19\n24 36\n8 49\n38 14\n", "7\n1 2\n1 1\n2 4\n3 5\n1 6\n2 7\n", "10\n8 1\n1 2\n8 9\n8 5\n1 3\n2 10\n1 6\n1 7\n8 4\n", "20\n19 16\n19 18\n20 7\n9 4\n6 17\n14 2\n9 15\n2 13\n5 11\n19 12\n12 20\n16 9\n11 8\n19 5\n3 1\n19 14\n5 3\n18 10\n19 6\n", "7\n1 2\n1 3\n2 4\n2 5\n4 6\n3 7\n", "4\n4 4\n2 3\n2 1\n", "4\n1 4\n2 2\n1 3\n", "20\n14 9\n12 13\n10 15\n2 1\n20 19\n16 6\n16 3\n17 8\n3 5\n2 11\n3 10\n15 8\n14 2\n6 4\n3 20\n5 18\n1 7\n1 16\n4 12\n", "20\n7 5\n14 13\n17 6\n3 8\n16 12\n18 9\n3 18\n14 1\n17 3\n15 2\n17 4\n2 11\n2 7\n15 17\n3 20\n16 10\n17 14\n2 16\n1 19\n", "50\n49 6\n43 7\n1 27\n19 35\n15 37\n16 12\n19 21\n16 28\n49 9\n48 39\n13 1\n2 48\n9 50\n44 3\n41 32\n48 31\n49 33\n6 11\n13 20\n49 22\n13 41\n48 29\n13 46\n15 47\n34 2\n49 13\n48 14\n34 24\n16 36\n13 40\n49 34\n49 17\n43 25\n19 23\n10 15\n19 26\n34 44\n16 42\n19 18\n46 8\n29 38\n1 45\n12 43\n13 16\n46 30\n15 5\n49 10\n11 19\n32 4\n", "10\n1 2\n5 6\n1 8\n2 9\n1 4\n8 10\n10 5\n2 7\n2 3\n", "5\n1 3\n1 3\n1 4\n4 5\n", "50\n16 4\n17 9\n31 19\n3 10\n8 1\n40 30\n3 31\n20 29\n47 27\n22 25\n32 34\n12 15\n40 32\n20 33\n47 12\n6 24\n46 41\n14 23\n12 35\n31 42\n46 28\n31 20\n46 37\n1 39\n29 49\n37 47\n40 6\n42 36\n47 2\n24 46\n2 13\n8 45\n41 3\n32 17\n4 7\n47 26\n28 8\n41 50\n34 44\n33 21\n25 5\n16 40\n3 14\n8 18\n28 11\n32 22\n2 38\n3 48\n44 43\n", "5\n5 1\n5 4\n4 3\n2 3\n", "60\n26 6\n59 30\n31 12\n31 3\n38 23\n55 29\n53 9\n38 56\n53 54\n29 21\n17 55\n59 38\n26 16\n24 59\n24 25\n17 35\n24 41\n30 15\n31 27\n8 44\n26 5\n26 48\n8 32\n53 17\n3 34\n3 51\n20 28\n47 10\n53 60\n36 42\n24 53\n59 22\n53 40\n26 52\n36 4\n59 8\n29 37\n36 20\n17 47\n53 18\n3 50\n30 2\n17 7\n8 58\n59 1\n31 11\n24 26\n24 43\n53 57\n59 45\n47 13\n26 46\n17 33\n30 31\n26 39\n26 19\n24 36\n8 49\n38 14\n", "7\n1 2\n1 3\n2 4\n2 5\n1 6\n1 7\n", "6\n1 2\n1 3\n2 4\n4 2\n2 6\n", "60\n26 6\n59 30\n31 12\n32 3\n38 23\n59 29\n53 9\n59 56\n53 54\n29 21\n17 55\n59 38\n26 16\n24 59\n24 25\n17 35\n24 41\n30 15\n31 27\n8 44\n26 5\n26 48\n8 32\n53 17\n3 34\n3 51\n20 28\n47 10\n53 60\n36 42\n24 53\n59 22\n53 40\n26 52\n36 4\n59 8\n29 37\n36 20\n17 47\n53 18\n3 50\n30 2\n17 7\n8 58\n59 1\n31 11\n24 26\n24 43\n53 57\n59 45\n47 13\n49 46\n17 33\n30 31\n30 39\n26 19\n24 36\n8 49\n38 14\n", "7\n1 2\n1 1\n3 4\n3 5\n1 6\n2 7\n", "10\n8 2\n1 2\n8 9\n8 5\n1 3\n2 10\n1 6\n1 7\n8 4\n", "4\n1 4\n2 2\n1 4\n", "20\n14 9\n12 13\n10 15\n2 1\n20 19\n16 6\n16 3\n17 8\n3 5\n2 11\n3 10\n2 8\n14 2\n6 4\n3 20\n5 18\n1 7\n1 16\n4 12\n", "20\n7 5\n14 14\n17 6\n3 8\n16 12\n18 9\n3 18\n14 1\n17 3\n15 2\n17 4\n2 11\n2 7\n15 17\n3 20\n16 10\n17 14\n2 16\n1 19\n", "50\n49 6\n43 7\n1 27\n19 35\n15 37\n16 12\n19 21\n16 28\n49 9\n48 39\n13 1\n2 48\n9 50\n44 3\n41 32\n48 31\n49 33\n6 11\n13 20\n49 22\n13 41\n48 29\n13 46\n15 47\n34 2\n49 13\n48 14\n34 24\n16 36\n23 40\n49 34\n49 17\n43 25\n19 23\n10 15\n19 26\n34 44\n16 42\n19 18\n46 8\n29 38\n1 45\n12 43\n13 16\n46 30\n15 5\n49 10\n11 19\n32 4\n", "5\n1 2\n1 3\n1 4\n4 5\n", "6\n1 2\n1 3\n2 4\n4 2\n1 6\n", "10\n8 2\n1 4\n8 9\n8 5\n1 3\n2 10\n1 6\n1 7\n8 4\n", "4\n1 4\n2 2\n2 4\n", "20\n14 9\n8 13\n10 15\n2 1\n20 19\n16 6\n16 3\n17 8\n3 5\n2 11\n3 10\n2 8\n14 2\n6 4\n3 20\n5 18\n1 7\n1 16\n4 12\n", "20\n7 5\n14 14\n17 6\n3 8\n16 12\n18 9\n3 18\n14 1\n11 3\n15 2\n17 4\n2 11\n2 7\n15 17\n3 20\n16 10\n17 14\n2 16\n1 19\n", "50\n49 6\n43 7\n1 27\n19 35\n15 37\n16 12\n19 21\n16 28\n49 17\n48 39\n13 1\n2 48\n9 50\n44 3\n41 32\n48 31\n49 33\n6 11\n13 20\n49 22\n13 41\n48 29\n13 46\n15 47\n34 2\n49 13\n48 14\n34 24\n16 36\n23 40\n49 34\n49 17\n43 25\n19 23\n10 15\n19 26\n34 44\n16 42\n19 18\n46 8\n29 38\n1 45\n12 43\n13 16\n46 30\n15 5\n49 10\n11 19\n32 4\n", "5\n1 1\n1 3\n1 4\n4 5\n", "10\n8 1\n1 2\n8 9\n7 5\n1 3\n1 10\n1 6\n1 7\n8 4\n", "7\n1 2\n3 3\n1 4\n1 5\n3 6\n3 7\n", "7\n1 2\n2 3\n3 5\n3 5\n1 6\n1 7\n", "7\n1 2\n1 3\n2 4\n2 5\n3 6\n1 7\n", "10\n9 5\n7 1\n9 10\n7 2\n9 4\n9 6\n2 9\n10 8\n1 3\n", "5\n1 2\n1 5\n2 3\n1 4\n", "8\n1 2\n2 3\n3 4\n1 7\n1 8\n4 5\n2 6\n", "50\n49 6\n43 7\n1 27\n19 35\n15 37\n16 12\n19 21\n16 28\n49 9\n48 39\n13 1\n2 48\n9 50\n44 3\n41 32\n48 31\n49 33\n6 11\n13 20\n49 22\n13 41\n1 29\n13 46\n15 47\n34 2\n49 13\n48 14\n34 24\n16 36\n13 40\n49 34\n49 17\n43 25\n11 23\n10 15\n19 26\n34 44\n16 42\n19 18\n46 8\n29 38\n1 45\n12 43\n13 16\n46 30\n15 5\n49 10\n11 19\n32 4\n", "5\n1 2\n1 3\n1 4\n1 5\n", "5\n5 1\n5 4\n4 2\n2 2\n", "7\n1 2\n2 4\n3 4\n5 5\n1 6\n1 7\n", "7\n1 2\n1 3\n2 1\n2 5\n1 6\n3 7\n", "6\n1 2\n2 3\n2 4\n4 5\n2 6\n", "6\n1 4\n1 3\n2 4\n4 5\n1 6\n", "10\n8 1\n1 2\n8 9\n8 5\n1 3\n3 10\n1 6\n1 7\n8 4\n", "10\n1 2\n5 6\n1 8\n2 9\n1 4\n8 10\n10 5\n2 7\n3 3\n", "5\n5 1\n1 4\n4 3\n2 3\n", "60\n26 6\n59 30\n31 12\n31 3\n38 23\n55 29\n53 9\n38 56\n53 54\n29 21\n17 55\n59 38\n26 16\n24 59\n24 25\n17 35\n24 41\n30 15\n31 27\n8 44\n26 5\n26 48\n8 32\n53 17\n3 34\n3 51\n20 28\n47 10\n53 60\n10 42\n24 53\n59 22\n53 40\n26 52\n36 4\n59 8\n29 37\n36 20\n17 47\n53 18\n3 50\n30 2\n17 7\n8 58\n59 1\n31 11\n24 26\n24 43\n53 57\n59 45\n47 13\n26 46\n17 33\n30 31\n26 39\n26 19\n24 36\n8 49\n38 14\n", "60\n26 6\n59 30\n31 12\n32 3\n38 23\n59 29\n53 9\n59 56\n53 54\n29 21\n17 55\n59 38\n26 16\n24 59\n24 25\n17 35\n24 41\n30 15\n31 27\n8 44\n26 5\n26 48\n8 32\n53 17\n3 34\n3 51\n20 28\n52 10\n53 60\n36 42\n24 53\n59 22\n53 40\n26 52\n36 4\n59 8\n29 37\n36 20\n17 47\n53 18\n3 50\n30 2\n17 7\n8 58\n59 1\n31 11\n24 26\n24 43\n53 57\n59 45\n47 13\n49 46\n17 33\n30 31\n30 39\n26 19\n24 36\n8 49\n38 14\n", "10\n8 2\n1 2\n8 9\n8 5\n1 3\n2 10\n1 6\n2 7\n8 4\n", "20\n14 9\n12 13\n10 15\n2 1\n20 19\n2 6\n16 3\n17 8\n3 5\n2 11\n3 10\n2 8\n14 2\n6 4\n3 20\n5 18\n1 7\n1 16\n4 12\n", "20\n7 5\n14 14\n17 6\n3 8\n16 12\n18 9\n3 18\n14 1\n17 3\n15 2\n17 4\n2 11\n2 7\n15 17\n3 17\n16 10\n17 14\n2 16\n1 19\n" ], "output": [ "YES", "NO", "NO", "YES", "NO", "YES", "NO", "NO", "NO", "YES", "NO", "NO", "NO", "NO", "YES", "NO", "NO", "YES", "NO", "NO", "NO", "YES", "NO", "YES", "NO", "NO\n", "YES\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "YES\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "YES\n", "NO\n", "NO\n", "NO\n", "YES\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "YES\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "YES\n", "NO\n", "NO\n", "NO\n", "NO\n", "YES\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "YES\n", "NO\n", "NO\n" ] }
2CODEFORCES
Below is a problem description that describes the problem. Write code in Python that appropriately solves the problem. ### Description: Note that this is the first problem of the two similar problems. You can hack this problem only if you solve both problems. You are given a tree with n nodes. In the beginning, 0 is written on all edges. In one operation, you can choose any 2 distinct leaves u, v and any real number x and add x to values written on all edges on the simple path between u and v. For example, on the picture below you can see the result of applying two operations to the graph: adding 2 on the path from 7 to 6, and then adding -0.5 on the path from 4 to 5. <image> Is it true that for any configuration of real numbers written on edges, we can achieve it with a finite number of operations? Leaf is a node of a tree of degree 1. Simple path is a path that doesn't contain any node twice. Input The first line contains a single integer n (2 ≀ n ≀ 10^5) β€” the number of nodes. Each of the next n-1 lines contains two integers u and v (1 ≀ u, v ≀ n, u β‰  v), meaning that there is an edge between nodes u and v. It is guaranteed that these edges form a tree. Output If there is a configuration of real numbers written on edges of the tree that we can't achieve by performing the operations, output "NO". Otherwise, output "YES". You can print each letter in any case (upper or lower). Examples Input 2 1 2 Output YES Input 3 1 2 2 3 Output NO Input 5 1 2 1 3 1 4 2 5 Output NO Input 6 1 2 1 3 1 4 2 5 2 6 Output YES Note In the first example, we can add any real x to the value written on the only edge (1, 2). <image> In the second example, one of configurations that we can't reach is 0 written on (1, 2) and 1 written on (2, 3). <image> Below you can see graphs from examples 3, 4: <image> <image> ### Input: 2 1 2 ### Output: YES ### Input: 3 1 2 2 3 ### Output: NO ### Code: m = int(input()) l = [0 for _ in range(m + 1)] for _ in range(m - 1): a,b = map(int, input().split()) l[a] += 1 l[b] += 1 if 2 in l: print("NO") else: print("YES")
1208_D. Restore Permutation_31
An array of integers p_{1},p_{2}, …,p_{n} is called a permutation if it contains each number from 1 to n exactly once. For example, the following arrays are permutations: [3,1,2], [1], [1,2,3,4,5] and [4,3,1,2]. The following arrays are not permutations: [2], [1,1], [2,3,4]. There is a hidden permutation of length n. For each index i, you are given s_{i}, which equals to the sum of all p_{j} such that j < i and p_{j} < p_{i}. In other words, s_i is the sum of elements before the i-th element that are smaller than the i-th element. Your task is to restore the permutation. Input The first line contains a single integer n (1 ≀ n ≀ 2 β‹… 10^{5}) β€” the size of the permutation. The second line contains n integers s_{1}, s_{2}, …, s_{n} (0 ≀ s_{i} ≀ (n(n-1))/(2)). It is guaranteed that the array s corresponds to a valid permutation of length n. Output Print n integers p_{1}, p_{2}, …, p_{n} β€” the elements of the restored permutation. We can show that the answer is always unique. Examples Input 3 0 0 0 Output 3 2 1 Input 2 0 1 Output 1 2 Input 5 0 1 1 1 10 Output 1 4 3 2 5 Note In the first example for each i there is no index j satisfying both conditions, hence s_i are always 0. In the second example for i = 2 it happens that j = 1 satisfies the conditions, so s_2 = p_1. In the third example for i = 2, 3, 4 only j = 1 satisfies the conditions, so s_2 = s_3 = s_4 = 1. For i = 5 all j = 1, 2, 3, 4 are possible, so s_5 = p_1 + p_2 + p_3 + p_4 = 10.
from sys import stdin,stdout class Tree(object): def __init__(self,n): self.tree=[0]*(4*n+10) self.b=[0]*(n+10) self.a=list(map(int,stdin.readline().split())) self.n=n def update(self,L,C,l,r,rt): if l==r: self.tree[rt]+=C return mid=(l+r)//2 if L<=mid: self.update(L,C,l,mid,rt<<1) else: self.update(L,C,mid+1,r,rt<<1|1) self.tree[rt]=self.tree[rt<<1]+self.tree[rt<<1|1] def query(self,s,l,r,rt): if l==r: return l mid=(l+r)//2 if self.tree[rt<<1]>s: return self.query(s,l,mid,rt<<1) else: return self.query(s-self.tree[rt<<1],mid+1,r,rt<<1|1) def slove(self): for i in range(n): self.update(i+1,i+1,1,n,1) for i in range(n,0,-1): self.b[i]=self.query(self.a[i-1],1,n,1) self.update(self.b[i],-self.b[i],1,n,1) for i in range(n): stdout.write('%d '%(self.b[i+1])) if __name__ == '__main__': n=int(stdin.readline()) seg=Tree(n) seg.slove()
{ "input": [ "3\n0 0 0\n", "5\n0 1 1 1 10\n", "2\n0 1\n", "100\n0 0 57 121 57 0 19 251 19 301 19 160 57 578 664 57 19 50 0 621 91 5 263 34 5 96 713 649 22 22 22 5 108 198 1412 1147 84 1326 1777 0 1780 132 2000 479 1314 525 68 690 1689 1431 1288 54 1514 1593 1037 1655 807 465 1674 1747 1982 423 837 139 1249 1997 1635 1309 661 334 3307 2691 21 3 533 1697 250 3920 0 343 96 242 2359 3877 3877 150 1226 96 358 829 228 2618 27 2854 119 1883 710 0 4248 435\n", "20\n0 1 7 15 30 15 59 42 1 4 1 36 116 36 16 136 10 36 46 36\n", "1\n0\n", "15\n0 0 3 3 13 3 6 34 47 12 20 6 6 21 55\n", "2\n0 0\n", "3\n0 1 1\n", "3\n0 0 1\n", "3\n0 2 0\n", "5\n0 0 1 1 10\n", "5\n0 0 1 1 6\n", "15\n0 0 0 3 13 3 6 34 47 12 20 6 6 21 55\n", "5\n0 1 1 1 6\n", "5\n0 0 0 1 10\n", "15\n0 0 0 3 13 3 3 34 47 12 20 6 6 21 55\n", "3\n0 0 3\n", "3\n0 1 3\n", "5\n0 0 0 1 6\n", "5\n0 0 1 1 1\n", "5\n0 1 1 1 3\n", "5\n0 0 1 1 3\n", "15\n0 0 1 3 13 3 3 34 47 12 20 6 6 21 55\n", "5\n0 1 1 1 1\n", "5\n0 0 0 0 10\n", "15\n0 0 0 1 13 3 3 34 47 12 20 6 6 21 55\n", "5\n0 0 0 0 6\n", "5\n0 0 0 1 3\n", "5\n0 0 0 0 3\n", "5\n0 0 2 0 3\n", "5\n0 0 0 1 1\n", "5\n0 0 0 0 1\n", "5\n0 0 0 0 0\n", "15\n0 1 3 3 13 3 6 34 47 12 20 6 6 21 55\n", "5\n0 0 0 2 0\n", "5\n0 0 0 3 6\n", "15\n0 0 1 3 13 3 6 34 47 12 20 6 6 21 55\n" ], "output": [ "3 2 1 ", "1 4 3 2 5 ", "1 2 ", "94 57 64 90 58 19 53 71 50 67 38 56 45 86 89 42 31 36 5 68 37 10 49 24 7 32 65 59 14 12 11 6 27 34 91 72 21 87 98 3 97 25 100 46 85 48 18 51 88 83 70 13 79 82 62 80 55 43 73 76 81 40 52 22 60 77 69 61 47 35 92 84 9 4 41 66 28 99 2 33 17 26 74 96 95 20 54 15 29 44 23 75 8 78 16 63 39 1 93 30 ", "1 6 8 15 17 12 18 16 3 4 2 14 20 13 7 19 5 10 11 9 ", "1 ", "2 1 15 10 12 3 6 13 14 8 9 5 4 7 11 ", "2 1\n", "1 3 2\n", "3 1 2\n", "2 3 1\n", "4 1 3 2 5\n", "5 1 3 2 4\n", "15 2 1 10 12 3 6 13 14 8 9 5 4 7 11\n", "1 5 3 2 4\n", "4 3 1 2 5\n", "15 2 1 10 12 6 3 13 14 8 9 5 4 7 11\n", "2 1 3\n", "1 2 3\n", "5 3 1 2 4\n", "5 1 4 3 2\n", "1 5 4 2 3\n", "5 1 4 2 3\n", "15 1 2 10 12 6 3 13 14 8 9 5 4 7 11\n", "1 5 4 3 2\n", "4 3 2 1 5\n", "15 10 1 2 12 6 3 13 14 8 9 5 4 7 11\n", "5 3 2 1 4\n", "5 4 1 2 3\n", "5 4 2 1 3\n", "5 2 4 1 3\n", "5 4 1 3 2\n", "5 4 3 1 2\n", "5 4 3 2 1\n", "1 2 15 10 12 3 6 13 14 8 9 5 4 7 11\n", "5 4 2 3 1\n", "5 2 1 3 4\n", "15 1 2 10 12 3 6 13 14 8 9 5 4 7 11\n" ] }
2CODEFORCES
Below is a problem description that describes the problem. Write code in Python that appropriately solves the problem. ### Description: An array of integers p_{1},p_{2}, …,p_{n} is called a permutation if it contains each number from 1 to n exactly once. For example, the following arrays are permutations: [3,1,2], [1], [1,2,3,4,5] and [4,3,1,2]. The following arrays are not permutations: [2], [1,1], [2,3,4]. There is a hidden permutation of length n. For each index i, you are given s_{i}, which equals to the sum of all p_{j} such that j < i and p_{j} < p_{i}. In other words, s_i is the sum of elements before the i-th element that are smaller than the i-th element. Your task is to restore the permutation. Input The first line contains a single integer n (1 ≀ n ≀ 2 β‹… 10^{5}) β€” the size of the permutation. The second line contains n integers s_{1}, s_{2}, …, s_{n} (0 ≀ s_{i} ≀ (n(n-1))/(2)). It is guaranteed that the array s corresponds to a valid permutation of length n. Output Print n integers p_{1}, p_{2}, …, p_{n} β€” the elements of the restored permutation. We can show that the answer is always unique. Examples Input 3 0 0 0 Output 3 2 1 Input 2 0 1 Output 1 2 Input 5 0 1 1 1 10 Output 1 4 3 2 5 Note In the first example for each i there is no index j satisfying both conditions, hence s_i are always 0. In the second example for i = 2 it happens that j = 1 satisfies the conditions, so s_2 = p_1. In the third example for i = 2, 3, 4 only j = 1 satisfies the conditions, so s_2 = s_3 = s_4 = 1. For i = 5 all j = 1, 2, 3, 4 are possible, so s_5 = p_1 + p_2 + p_3 + p_4 = 10. ### Input: 3 0 0 0 ### Output: 3 2 1 ### Input: 5 0 1 1 1 10 ### Output: 1 4 3 2 5 ### Code: from sys import stdin,stdout class Tree(object): def __init__(self,n): self.tree=[0]*(4*n+10) self.b=[0]*(n+10) self.a=list(map(int,stdin.readline().split())) self.n=n def update(self,L,C,l,r,rt): if l==r: self.tree[rt]+=C return mid=(l+r)//2 if L<=mid: self.update(L,C,l,mid,rt<<1) else: self.update(L,C,mid+1,r,rt<<1|1) self.tree[rt]=self.tree[rt<<1]+self.tree[rt<<1|1] def query(self,s,l,r,rt): if l==r: return l mid=(l+r)//2 if self.tree[rt<<1]>s: return self.query(s,l,mid,rt<<1) else: return self.query(s-self.tree[rt<<1],mid+1,r,rt<<1|1) def slove(self): for i in range(n): self.update(i+1,i+1,1,n,1) for i in range(n,0,-1): self.b[i]=self.query(self.a[i-1],1,n,1) self.update(self.b[i],-self.b[i],1,n,1) for i in range(n): stdout.write('%d '%(self.b[i+1])) if __name__ == '__main__': n=int(stdin.readline()) seg=Tree(n) seg.slove()
1227_D1. Optimal Subsequences (Easy Version)_34
This is the easier version of the problem. In this version 1 ≀ n, m ≀ 100. You can hack this problem only if you solve and lock both problems. You are given a sequence of integers a=[a_1,a_2,...,a_n] of length n. Its subsequence is obtained by removing zero or more elements from the sequence a (they do not necessarily go consecutively). For example, for the sequence a=[11,20,11,33,11,20,11]: * [11,20,11,33,11,20,11], [11,20,11,33,11,20], [11,11,11,11], [20], [33,20] are subsequences (these are just some of the long list); * [40], [33,33], [33,20,20], [20,20,11,11] are not subsequences. Suppose that an additional non-negative integer k (1 ≀ k ≀ n) is given, then the subsequence is called optimal if: * it has a length of k and the sum of its elements is the maximum possible among all subsequences of length k; * and among all subsequences of length k that satisfy the previous item, it is lexicographically minimal. Recall that the sequence b=[b_1, b_2, ..., b_k] is lexicographically smaller than the sequence c=[c_1, c_2, ..., c_k] if the first element (from the left) in which they differ less in the sequence b than in c. Formally: there exists t (1 ≀ t ≀ k) such that b_1=c_1, b_2=c_2, ..., b_{t-1}=c_{t-1} and at the same time b_t<c_t. For example: * [10, 20, 20] lexicographically less than [10, 21, 1], * [7, 99, 99] is lexicographically less than [10, 21, 1], * [10, 21, 0] is lexicographically less than [10, 21, 1]. You are given a sequence of a=[a_1,a_2,...,a_n] and m requests, each consisting of two numbers k_j and pos_j (1 ≀ k ≀ n, 1 ≀ pos_j ≀ k_j). For each query, print the value that is in the index pos_j of the optimal subsequence of the given sequence a for k=k_j. For example, if n=4, a=[10,20,30,20], k_j=2, then the optimal subsequence is [20,30] β€” it is the minimum lexicographically among all subsequences of length 2 with the maximum total sum of items. Thus, the answer to the request k_j=2, pos_j=1 is the number 20, and the answer to the request k_j=2, pos_j=2 is the number 30. Input The first line contains an integer n (1 ≀ n ≀ 100) β€” the length of the sequence a. The second line contains elements of the sequence a: integer numbers a_1, a_2, ..., a_n (1 ≀ a_i ≀ 10^9). The third line contains an integer m (1 ≀ m ≀ 100) β€” the number of requests. The following m lines contain pairs of integers k_j and pos_j (1 ≀ k ≀ n, 1 ≀ pos_j ≀ k_j) β€” the requests. Output Print m integers r_1, r_2, ..., r_m (1 ≀ r_j ≀ 10^9) one per line: answers to the requests in the order they appear in the input. The value of r_j should be equal to the value contained in the position pos_j of the optimal subsequence for k=k_j. Examples Input 3 10 20 10 6 1 1 2 1 2 2 3 1 3 2 3 3 Output 20 10 20 10 20 10 Input 7 1 2 1 3 1 2 1 9 2 1 2 2 3 1 3 2 3 3 1 1 7 1 7 7 7 4 Output 2 3 2 3 2 3 1 1 3 Note In the first example, for a=[10,20,10] the optimal subsequences are: * for k=1: [20], * for k=2: [10,20], * for k=3: [10,20,10].
# class SegmentTree(): # adapted from https://www.geeksforgeeks.org/segment-tree-efficient-implementation/ # def __init__(self,arr,func,initialRes=0): # self.f=func # self.N=len(arr) # self.tree=[0 for _ in range(2*self.N)] # self.initialRes=initialRes # for i in range(self.N): # self.tree[self.N+i]=arr[i] # for i in range(self.N-1,0,-1): # self.tree[i]=self.f(self.tree[i<<1],self.tree[i<<1|1]) # def updateTreeNode(self,idx,value): #update value at arr[idx] # self.tree[idx+self.N]=value # idx+=self.N # i=idx # while i>1: # self.tree[i>>1]=self.f(self.tree[i],self.tree[i^1]) # i>>=1 # def query(self,l,r): #get sum (or whatever function) on interval [l,r] inclusive # r+=1 # res=self.initialRes # l+=self.N # r+=self.N # while l<r: # if l&1: # res=self.f(res,self.tree[l]) # l+=1 # if r&1: # r-=1 # res=self.f(res,self.tree[r]) # l>>=1 # r>>=1 # return res # def getMaxSegTree(arr): # return SegmentTree(arr,lambda a,b:max(a,b),initialRes=-float('inf')) # def getMinSegTree(arr): # return SegmentTree(arr,lambda a,b:min(a,b),initialRes=float('inf')) # def getSumSegTree(arr): # return SegmentTree(arr,lambda a,b:a+b,initialRes=0) from collections import Counter def main(): # mlogn solution n=int(input()) a=readIntArr() b=sorted(a,reverse=True) m=int(input()) allans=[] for _ in range(m): k,pos=readIntArr() cnt=Counter(b[:k]) totalCnts=0 for x in a: if cnt[x]>0: cnt[x]-=1 totalCnts+=1 if totalCnts==pos: allans.append(x) break multiLineArrayPrint(allans) return import sys input=sys.stdin.buffer.readline #FOR READING PURE INTEGER INPUTS (space separation ok) # input=lambda: sys.stdin.readline().rstrip("\r\n") #FOR READING STRING/TEXT INPUTS. def oneLineArrayPrint(arr): print(' '.join([str(x) for x in arr])) def multiLineArrayPrint(arr): print('\n'.join([str(x) for x in arr])) def multiLineArrayOfArraysPrint(arr): print('\n'.join([' '.join([str(x) for x in y]) for y in arr])) def readIntArr(): return [int(x) for x in input().split()] # def readFloatArr(): # return [float(x) for x in input().split()] def makeArr(defaultValFactory,dimensionArr): # eg. makeArr(lambda:0,[n,m]) dv=defaultValFactory;da=dimensionArr if len(da)==1:return [dv() for _ in range(da[0])] else:return [makeArr(dv,da[1:]) for _ in range(da[0])] def queryInteractive(i,j): print('? {} {}'.format(i,j)) sys.stdout.flush() return int(input()) def answerInteractive(ans): print('! {}'.format(' '.join([str(x) for x in ans]))) sys.stdout.flush() inf=float('inf') MOD=10**9+7 # MOD=998244353 for _abc in range(1): main()
{ "input": [ "3\n10 20 10\n6\n1 1\n2 1\n2 2\n3 1\n3 2\n3 3\n", "7\n1 2 1 3 1 2 1\n9\n2 1\n2 2\n3 1\n3 2\n3 3\n1 1\n7 1\n7 7\n7 4\n", "2\n1 10\n3\n2 2\n2 1\n1 1\n", "2\n3922 3922\n3\n2 2\n2 1\n1 1\n", "1\n1000000000\n1\n1 1\n", "1\n1\n3\n1 1\n1 1\n1 1\n", "5\n3 1 4 1 2\n15\n5 5\n5 4\n5 3\n5 2\n5 1\n4 4\n4 3\n4 2\n4 1\n3 3\n3 2\n3 1\n2 2\n2 1\n1 1\n", "2\n392222 322\n3\n2 2\n2 1\n1 1\n", "2\n1 10\n2\n2 2\n2 1\n1 1\n", "2\n3922 3922\n1\n2 2\n2 1\n1 1\n", "1\n1\n2\n1 1\n1 1\n1 1\n", "2\n392222 187\n3\n2 2\n2 1\n1 1\n", "2\n4612 3922\n1\n2 1\n2 0\n1 1\n", "2\n3555 3922\n3\n2 2\n2 1\n1 1\n", "5\n3 1 4 2 2\n15\n5 5\n5 4\n5 3\n5 2\n5 1\n4 4\n4 3\n4 2\n4 1\n3 3\n3 2\n3 1\n2 2\n2 1\n1 1\n", "3\n10 20 10\n2\n1 1\n2 1\n2 2\n3 1\n3 2\n3 3\n", "7\n1 2 1 6 1 2 1\n9\n2 1\n2 2\n3 1\n3 2\n3 3\n1 1\n7 1\n7 7\n7 4\n", "2\n1 10\n2\n2 2\n2 2\n1 1\n", "2\n392222 187\n3\n2 2\n2 2\n1 1\n", "2\n392222 313\n3\n2 2\n2 2\n1 1\n", "2\n176692 313\n3\n2 2\n2 2\n1 1\n", "2\n3259 4209\n1\n2 1\n2 1\n1 2\n", "2\n3259 4209\n2\n2 1\n2 1\n1 2\n", "2\n3922 3052\n1\n2 2\n2 1\n3 1\n", "2\n2189 2193\n1\n2 2\n0 2\n3 0\n", "2\n2189 2193\n1\n2 1\n0 2\n3 0\n", "2\n1426 2193\n1\n2 1\n0 2\n3 0\n", "2\n2436 2072\n1\n2 1\n0 2\n5 0\n", "2\n1 7\n3\n2 2\n2 1\n1 1\n", "2\n2123 3922\n3\n2 2\n2 1\n1 1\n", "5\n3 1 4 1 2\n15\n5 5\n5 3\n5 3\n5 2\n5 1\n4 4\n4 3\n4 2\n4 1\n3 3\n3 2\n3 1\n2 2\n2 1\n1 1\n", "2\n336365 322\n3\n2 2\n2 1\n1 1\n", "7\n1 2 1 3 1 2 1\n9\n2 1\n2 2\n5 1\n3 2\n3 3\n1 1\n7 1\n7 7\n7 4\n", "2\n3922 265\n1\n2 2\n2 1\n1 1\n", "2\n392222 16\n3\n2 2\n2 1\n1 1\n", "2\n392222 50\n3\n2 2\n2 2\n1 1\n", "2\n2842 3492\n1\n2 2\n2 0\n1 0\n", "2\n3922 5235\n1\n2 2\n2 2\n3 1\n", "2\n673 2193\n1\n2 1\n0 2\n3 0\n", "2\n1426 2072\n1\n2 2\n0 2\n5 0\n", "2\n1 7\n1\n2 2\n2 1\n1 1\n", "5\n3 1 4 1 2\n15\n5 5\n5 3\n5 3\n5 2\n5 1\n4 4\n4 3\n4 2\n4 1\n3 3\n3 2\n3 1\n2 2\n2 2\n1 1\n", "7\n1 2 1 3 1 2 1\n9\n2 1\n2 2\n5 1\n3 2\n3 3\n1 1\n7 1\n7 7\n7 5\n", "2\n8322 3922\n1\n2 1\n2 0\n1 2\n", "2\n3922 1526\n1\n2 2\n3 2\n3 0\n", "2\n3922 3922\n1\n2 1\n2 1\n1 1\n", "1\n1\n2\n1 1\n1 1\n2 1\n", "2\n3922 3922\n1\n2 1\n2 0\n1 1\n", "2\n3922 3922\n1\n2 2\n2 1\n2 1\n", "2\n3922 4209\n1\n2 1\n2 1\n1 1\n", "2\n3922 3922\n1\n2 2\n2 0\n1 1\n", "2\n4612 6198\n1\n2 1\n2 0\n1 1\n", "2\n3922 3922\n1\n2 2\n2 0\n2 1\n", "2\n3922 4209\n1\n2 1\n2 1\n1 2\n", "2\n1723 3922\n1\n2 2\n2 0\n1 1\n", "2\n3922 3922\n1\n2 2\n2 0\n3 1\n", "2\n2842 3922\n1\n2 2\n2 0\n1 1\n", "2\n3922 3922\n1\n2 2\n2 1\n3 1\n", "2\n2842 3922\n1\n2 2\n3 0\n1 1\n", "2\n2842 3922\n1\n2 2\n2 0\n1 0\n", "2\n3922 3052\n1\n2 2\n2 2\n3 1\n", "2\n2842 3922\n1\n2 2\n2 -1\n1 0\n", "2\n3922 3052\n1\n2 2\n2 2\n3 0\n", "2\n2189 3052\n1\n2 2\n2 2\n3 0\n", "2\n2189 3052\n1\n2 2\n1 2\n3 0\n", "2\n2189 3052\n1\n2 2\n0 2\n3 0\n", "2\n1426 2193\n1\n2 1\n0 2\n5 0\n", "2\n1426 2072\n1\n2 1\n0 2\n5 0\n", "2\n2436 550\n1\n2 1\n0 2\n5 0\n", "2\n3922 3922\n1\n2 1\n2 1\n1 0\n", "2\n3922 4480\n1\n2 1\n2 0\n1 1\n", "2\n4612 3922\n1\n2 1\n2 0\n1 2\n", "5\n3 1 4 2 2\n15\n5 5\n5 4\n5 3\n5 2\n5 1\n4 3\n4 3\n4 2\n4 1\n3 3\n3 2\n3 1\n2 2\n2 1\n1 1\n", "2\n3922 3922\n1\n2 2\n3 1\n1 1\n", "2\n3922 2384\n1\n2 1\n2 1\n1 1\n", "2\n4612 6198\n1\n2 1\n2 1\n1 1\n", "2\n3922 6047\n1\n2 1\n2 1\n1 2\n", "2\n1723 3922\n1\n2 2\n2 0\n2 1\n", "2\n3922 3922\n1\n2 2\n2 0\n5 1\n", "2\n3259 4209\n1\n2 1\n2 1\n1 0\n", "2\n580 3922\n1\n2 2\n2 1\n3 1\n", "2\n3922 3052\n1\n2 2\n3 1\n3 1\n", "2\n2842 3922\n1\n2 2\n3 -1\n1 0\n", "2\n3922 3052\n1\n2 2\n3 2\n3 0\n", "2\n833 3052\n1\n2 2\n2 2\n3 0\n", "2\n1908 3052\n1\n2 2\n1 2\n3 0\n", "2\n2189 3052\n1\n2 2\n0 3\n3 0\n", "2\n2189 2193\n1\n2 2\n0 2\n3 1\n", "2\n2189 2193\n1\n2 1\n0 2\n6 0\n", "2\n1426 2855\n1\n2 1\n0 2\n5 0\n", "2\n2436 2072\n1\n2 1\n0 0\n5 0\n", "2\n3922 265\n1\n2 2\n0 1\n1 1\n", "2\n3922 3922\n1\n2 1\n0 1\n1 0\n", "2\n3922 3730\n1\n2 1\n2 0\n1 1\n", "2\n3922 3922\n1\n2 2\n3 0\n1 1\n", "2\n4612 1428\n1\n2 1\n2 1\n1 1\n", "2\n3922 6047\n1\n2 1\n2 2\n1 2\n", "2\n3922 3922\n1\n2 2\n2 0\n4 1\n", "2\n3922 5235\n1\n2 1\n2 2\n3 1\n", "2\n818 3052\n1\n2 2\n2 2\n3 0\n", "2\n1908 3052\n1\n2 2\n0 2\n3 0\n", "2\n2189 3052\n1\n2 2\n0 3\n3 -1\n", "2\n2189 2193\n1\n2 2\n0 2\n6 1\n", "2\n2189 2193\n1\n2 1\n0 2\n10 0\n" ], "output": [ "20\n10\n20\n10\n20\n10\n", "2\n3\n2\n3\n2\n3\n1\n1\n3\n", "10\n1\n10\n", "3922\n3922\n3922\n", "1000000000\n", "1\n1\n1\n", "2\n1\n4\n1\n3\n2\n4\n1\n3\n2\n4\n3\n4\n3\n4\n", "322\n392222\n392222\n", "10\n1\n", "3922\n", "1\n1\n", "187\n392222\n392222\n", "4612\n", "3922\n3555\n3922\n", "2\n2\n4\n1\n3\n2\n2\n4\n3\n2\n4\n3\n4\n3\n4\n", "20\n10\n", "2\n6\n2\n6\n2\n6\n1\n1\n6\n", "10\n10\n", "187\n187\n392222\n", "313\n313\n392222\n", "313\n313\n176692\n", "3259\n", "3259\n3259\n", "3052\n", "2193\n", "2189\n", "1426\n", "2436\n", "7\n1\n7\n", "3922\n2123\n3922\n", "2\n4\n4\n1\n3\n2\n4\n1\n3\n2\n4\n3\n4\n3\n4\n", "322\n336365\n336365\n", "2\n3\n1\n3\n2\n3\n1\n1\n3\n", "265\n", "16\n392222\n392222\n", "50\n50\n392222\n", "3492\n", "5235\n", "673\n", "2072\n", "7\n", "2\n4\n4\n1\n3\n2\n4\n1\n3\n2\n4\n3\n4\n4\n4\n", "2\n3\n1\n3\n2\n3\n1\n1\n1\n", "8322\n", "1526\n", "3922\n", "1\n1\n", "3922\n", "3922\n", "3922\n", "3922\n", "4612\n", "3922\n", "3922\n", "3922\n", "3922\n", "3922\n", "3922\n", "3922\n", "3922\n", "3052\n", "3922\n", "3052\n", "3052\n", "3052\n", "3052\n", "1426\n", "1426\n", "2436\n", "3922\n", "3922\n", "4612\n", "2\n2\n4\n1\n3\n2\n2\n4\n3\n2\n4\n3\n4\n3\n4\n", "3922\n", "3922\n", "4612\n", "3922\n", "3922\n", "3922\n", "3259\n", "3922\n", "3052\n", "3922\n", "3052\n", "3052\n", "3052\n", "3052\n", "2193\n", "2189\n", "1426\n", "2436\n", "265\n", "3922\n", "3922\n", "3922\n", "4612\n", "3922\n", "3922\n", "3922\n", "3052\n", "3052\n", "3052\n", "2193\n", "2189\n" ] }
2CODEFORCES
Below is a problem description that describes the problem. Write code in Python that appropriately solves the problem. ### Description: This is the easier version of the problem. In this version 1 ≀ n, m ≀ 100. You can hack this problem only if you solve and lock both problems. You are given a sequence of integers a=[a_1,a_2,...,a_n] of length n. Its subsequence is obtained by removing zero or more elements from the sequence a (they do not necessarily go consecutively). For example, for the sequence a=[11,20,11,33,11,20,11]: * [11,20,11,33,11,20,11], [11,20,11,33,11,20], [11,11,11,11], [20], [33,20] are subsequences (these are just some of the long list); * [40], [33,33], [33,20,20], [20,20,11,11] are not subsequences. Suppose that an additional non-negative integer k (1 ≀ k ≀ n) is given, then the subsequence is called optimal if: * it has a length of k and the sum of its elements is the maximum possible among all subsequences of length k; * and among all subsequences of length k that satisfy the previous item, it is lexicographically minimal. Recall that the sequence b=[b_1, b_2, ..., b_k] is lexicographically smaller than the sequence c=[c_1, c_2, ..., c_k] if the first element (from the left) in which they differ less in the sequence b than in c. Formally: there exists t (1 ≀ t ≀ k) such that b_1=c_1, b_2=c_2, ..., b_{t-1}=c_{t-1} and at the same time b_t<c_t. For example: * [10, 20, 20] lexicographically less than [10, 21, 1], * [7, 99, 99] is lexicographically less than [10, 21, 1], * [10, 21, 0] is lexicographically less than [10, 21, 1]. You are given a sequence of a=[a_1,a_2,...,a_n] and m requests, each consisting of two numbers k_j and pos_j (1 ≀ k ≀ n, 1 ≀ pos_j ≀ k_j). For each query, print the value that is in the index pos_j of the optimal subsequence of the given sequence a for k=k_j. For example, if n=4, a=[10,20,30,20], k_j=2, then the optimal subsequence is [20,30] β€” it is the minimum lexicographically among all subsequences of length 2 with the maximum total sum of items. Thus, the answer to the request k_j=2, pos_j=1 is the number 20, and the answer to the request k_j=2, pos_j=2 is the number 30. Input The first line contains an integer n (1 ≀ n ≀ 100) β€” the length of the sequence a. The second line contains elements of the sequence a: integer numbers a_1, a_2, ..., a_n (1 ≀ a_i ≀ 10^9). The third line contains an integer m (1 ≀ m ≀ 100) β€” the number of requests. The following m lines contain pairs of integers k_j and pos_j (1 ≀ k ≀ n, 1 ≀ pos_j ≀ k_j) β€” the requests. Output Print m integers r_1, r_2, ..., r_m (1 ≀ r_j ≀ 10^9) one per line: answers to the requests in the order they appear in the input. The value of r_j should be equal to the value contained in the position pos_j of the optimal subsequence for k=k_j. Examples Input 3 10 20 10 6 1 1 2 1 2 2 3 1 3 2 3 3 Output 20 10 20 10 20 10 Input 7 1 2 1 3 1 2 1 9 2 1 2 2 3 1 3 2 3 3 1 1 7 1 7 7 7 4 Output 2 3 2 3 2 3 1 1 3 Note In the first example, for a=[10,20,10] the optimal subsequences are: * for k=1: [20], * for k=2: [10,20], * for k=3: [10,20,10]. ### Input: 3 10 20 10 6 1 1 2 1 2 2 3 1 3 2 3 3 ### Output: 20 10 20 10 20 10 ### Input: 7 1 2 1 3 1 2 1 9 2 1 2 2 3 1 3 2 3 3 1 1 7 1 7 7 7 4 ### Output: 2 3 2 3 2 3 1 1 3 ### Code: # class SegmentTree(): # adapted from https://www.geeksforgeeks.org/segment-tree-efficient-implementation/ # def __init__(self,arr,func,initialRes=0): # self.f=func # self.N=len(arr) # self.tree=[0 for _ in range(2*self.N)] # self.initialRes=initialRes # for i in range(self.N): # self.tree[self.N+i]=arr[i] # for i in range(self.N-1,0,-1): # self.tree[i]=self.f(self.tree[i<<1],self.tree[i<<1|1]) # def updateTreeNode(self,idx,value): #update value at arr[idx] # self.tree[idx+self.N]=value # idx+=self.N # i=idx # while i>1: # self.tree[i>>1]=self.f(self.tree[i],self.tree[i^1]) # i>>=1 # def query(self,l,r): #get sum (or whatever function) on interval [l,r] inclusive # r+=1 # res=self.initialRes # l+=self.N # r+=self.N # while l<r: # if l&1: # res=self.f(res,self.tree[l]) # l+=1 # if r&1: # r-=1 # res=self.f(res,self.tree[r]) # l>>=1 # r>>=1 # return res # def getMaxSegTree(arr): # return SegmentTree(arr,lambda a,b:max(a,b),initialRes=-float('inf')) # def getMinSegTree(arr): # return SegmentTree(arr,lambda a,b:min(a,b),initialRes=float('inf')) # def getSumSegTree(arr): # return SegmentTree(arr,lambda a,b:a+b,initialRes=0) from collections import Counter def main(): # mlogn solution n=int(input()) a=readIntArr() b=sorted(a,reverse=True) m=int(input()) allans=[] for _ in range(m): k,pos=readIntArr() cnt=Counter(b[:k]) totalCnts=0 for x in a: if cnt[x]>0: cnt[x]-=1 totalCnts+=1 if totalCnts==pos: allans.append(x) break multiLineArrayPrint(allans) return import sys input=sys.stdin.buffer.readline #FOR READING PURE INTEGER INPUTS (space separation ok) # input=lambda: sys.stdin.readline().rstrip("\r\n") #FOR READING STRING/TEXT INPUTS. def oneLineArrayPrint(arr): print(' '.join([str(x) for x in arr])) def multiLineArrayPrint(arr): print('\n'.join([str(x) for x in arr])) def multiLineArrayOfArraysPrint(arr): print('\n'.join([' '.join([str(x) for x in y]) for y in arr])) def readIntArr(): return [int(x) for x in input().split()] # def readFloatArr(): # return [float(x) for x in input().split()] def makeArr(defaultValFactory,dimensionArr): # eg. makeArr(lambda:0,[n,m]) dv=defaultValFactory;da=dimensionArr if len(da)==1:return [dv() for _ in range(da[0])] else:return [makeArr(dv,da[1:]) for _ in range(da[0])] def queryInteractive(i,j): print('? {} {}'.format(i,j)) sys.stdout.flush() return int(input()) def answerInteractive(ans): print('! {}'.format(' '.join([str(x) for x in ans]))) sys.stdout.flush() inf=float('inf') MOD=10**9+7 # MOD=998244353 for _abc in range(1): main()
1269_E. K Integers_38
You are given a permutation p_1, p_2, …, p_n. In one move you can swap two adjacent values. You want to perform a minimum number of moves, such that in the end there will exist a subsegment 1,2,…, k, in other words in the end there should be an integer i, 1 ≀ i ≀ n-k+1 such that p_i = 1, p_{i+1} = 2, …, p_{i+k-1}=k. Let f(k) be the minimum number of moves that you need to make a subsegment with values 1,2,…,k appear in the permutation. You need to find f(1), f(2), …, f(n). Input The first line of input contains one integer n (1 ≀ n ≀ 200 000): the number of elements in the permutation. The next line of input contains n integers p_1, p_2, …, p_n: given permutation (1 ≀ p_i ≀ n). Output Print n integers, the minimum number of moves that you need to make a subsegment with values 1,2,…,k appear in the permutation, for k=1, 2, …, n. Examples Input 5 5 4 3 2 1 Output 0 1 3 6 10 Input 3 1 2 3 Output 0 0 0
n = int(input()) a = [0] + list(map(int, input().split())) pos, pb, ps = [[0] * (n + 1) for x in range(3)] def add(bit, i, val): while i <= n: bit[i] += val i += i & -i def sum(bit, i): res = 0 while i > 0: res += bit[i] i -= i & -i return res def find(bit, sum): i, t = 0, 0 if sum == 0: return 0 for k in range(17, -1, -1): i += 1 << k if i <= n and t + bit[i] < sum: t += bit[i] else: i -= 1 << k return i + 1 for i in range(1, n + 1): pos[a[i]] = i invSum = 0 totalSum = 0 for i in range(1, n + 1): totalSum += pos[i] invSum += i - sum(pb, pos[i]) - 1 add(pb, pos[i], 1) add(ps, pos[i], pos[i]) mid = find(pb, i // 2) if i % 2 == 1: mid2 = find(pb, i // 2 + 1) seqSum = (i + 1) * (i // 2) // 2 else: mid2 = mid seqSum = i * (i // 2) // 2 leftSum = sum(ps, mid) rightSum = totalSum - sum(ps, mid2) print(rightSum - leftSum - seqSum + invSum, end=" ")
{ "input": [ "3\n1 2 3\n", "5\n5 4 3 2 1\n", "1\n1\n", "100\n98 52 63 2 18 96 31 58 84 40 41 45 66 100 46 71 26 48 81 20 73 91 68 76 13 93 17 29 64 95 79 21 55 75 19 85 54 51 89 78 15 87 43 59 36 1 90 35 65 56 62 28 86 5 82 49 3 99 33 9 92 32 74 69 27 22 77 16 44 94 34 6 57 70 23 12 61 25 8 11 67 47 83 88 10 14 30 7 97 60 42 37 24 38 53 50 4 80 72 39\n", "10\n5 1 6 2 8 3 4 10 9 7\n", "5\n5 4 3 1 2\n", "3\n3 2 1\n", "3\n2 3 1\n", "10\n5 1 6 2 8 4 3 10 9 7\n", "3\n3 1 2\n", "3\n2 1 3\n", "5\n5 4 1 2 3\n", "3\n1 3 2\n" ], "output": [ "0 0 0\n", "0 1 3 6 10\n", "0\n", "0 42 52 101 101 117 146 166 166 188 194 197 249 258 294 298 345 415 445 492 522 529 540 562 569 628 628 644 684 699 765 766 768 774 791 812 828 844 863 931 996 1011 1036 1040 1105 1166 1175 1232 1237 1251 1282 1364 1377 1409 1445 1455 1461 1534 1553 1565 1572 1581 1664 1706 1715 1779 1787 1837 1841 1847 1909 1919 1973 1976 2010 2060 2063 2087 2125 2133 2192 2193 2196 2276 2305 2305 2324 2327 2352 2361 2417 2418 2467 2468 2510 2598 2599 2697 2697 2770\n", "0 1 2 3 8 9 12 12 13 13\n", "0 0 2 5 9\n", "0 1 3\n", "0 2 2\n", "0 1 3 4 9 10 13 13 14 14\n", "0 0 2\n", "0 1 1\n", "0 0 0 3 7\n", "0 1 1\n" ] }
2CODEFORCES
Below is a problem description that describes the problem. Write code in Python that appropriately solves the problem. ### Description: You are given a permutation p_1, p_2, …, p_n. In one move you can swap two adjacent values. You want to perform a minimum number of moves, such that in the end there will exist a subsegment 1,2,…, k, in other words in the end there should be an integer i, 1 ≀ i ≀ n-k+1 such that p_i = 1, p_{i+1} = 2, …, p_{i+k-1}=k. Let f(k) be the minimum number of moves that you need to make a subsegment with values 1,2,…,k appear in the permutation. You need to find f(1), f(2), …, f(n). Input The first line of input contains one integer n (1 ≀ n ≀ 200 000): the number of elements in the permutation. The next line of input contains n integers p_1, p_2, …, p_n: given permutation (1 ≀ p_i ≀ n). Output Print n integers, the minimum number of moves that you need to make a subsegment with values 1,2,…,k appear in the permutation, for k=1, 2, …, n. Examples Input 5 5 4 3 2 1 Output 0 1 3 6 10 Input 3 1 2 3 Output 0 0 0 ### Input: 3 1 2 3 ### Output: 0 0 0 ### Input: 5 5 4 3 2 1 ### Output: 0 1 3 6 10 ### Code: n = int(input()) a = [0] + list(map(int, input().split())) pos, pb, ps = [[0] * (n + 1) for x in range(3)] def add(bit, i, val): while i <= n: bit[i] += val i += i & -i def sum(bit, i): res = 0 while i > 0: res += bit[i] i -= i & -i return res def find(bit, sum): i, t = 0, 0 if sum == 0: return 0 for k in range(17, -1, -1): i += 1 << k if i <= n and t + bit[i] < sum: t += bit[i] else: i -= 1 << k return i + 1 for i in range(1, n + 1): pos[a[i]] = i invSum = 0 totalSum = 0 for i in range(1, n + 1): totalSum += pos[i] invSum += i - sum(pb, pos[i]) - 1 add(pb, pos[i], 1) add(ps, pos[i], pos[i]) mid = find(pb, i // 2) if i % 2 == 1: mid2 = find(pb, i // 2 + 1) seqSum = (i + 1) * (i // 2) // 2 else: mid2 = mid seqSum = i * (i // 2) // 2 leftSum = sum(ps, mid) rightSum = totalSum - sum(ps, mid2) print(rightSum - leftSum - seqSum + invSum, end=" ")
1291_E. Prefix Enlightenment_41
There are n lamps on a line, numbered from 1 to n. Each one has an initial state off (0) or on (1). You're given k subsets A_1, …, A_k of \{1, 2, ..., n\}, such that the intersection of any three subsets is empty. In other words, for all 1 ≀ i_1 < i_2 < i_3 ≀ k, A_{i_1} ∩ A_{i_2} ∩ A_{i_3} = βˆ…. In one operation, you can choose one of these k subsets and switch the state of all lamps in it. It is guaranteed that, with the given subsets, it's possible to make all lamps be simultaneously on using this type of operation. Let m_i be the minimum number of operations you have to do in order to make the i first lamps be simultaneously on. Note that there is no condition upon the state of other lamps (between i+1 and n), they can be either off or on. You have to compute m_i for all 1 ≀ i ≀ n. Input The first line contains two integers n and k (1 ≀ n, k ≀ 3 β‹… 10^5). The second line contains a binary string of length n, representing the initial state of each lamp (the lamp i is off if s_i = 0, on if s_i = 1). The description of each one of the k subsets follows, in the following format: The first line of the description contains a single integer c (1 ≀ c ≀ n) β€” the number of elements in the subset. The second line of the description contains c distinct integers x_1, …, x_c (1 ≀ x_i ≀ n) β€” the elements of the subset. It is guaranteed that: * The intersection of any three subsets is empty; * It's possible to make all lamps be simultaneously on using some operations. Output You must output n lines. The i-th line should contain a single integer m_i β€” the minimum number of operations required to make the lamps 1 to i be simultaneously on. Examples Input 7 3 0011100 3 1 4 6 3 3 4 7 2 2 3 Output 1 2 3 3 3 3 3 Input 8 6 00110011 3 1 3 8 5 1 2 5 6 7 2 6 8 2 3 5 2 4 7 1 2 Output 1 1 1 1 1 1 4 4 Input 5 3 00011 3 1 2 3 1 4 3 3 4 5 Output 1 1 1 1 1 Input 19 5 1001001001100000110 2 2 3 2 5 6 2 8 9 5 12 13 14 15 16 1 19 Output 0 1 1 1 2 2 2 3 3 3 3 4 4 4 4 4 4 4 5 Note In the first example: * For i = 1, we can just apply one operation on A_1, the final states will be 1010110; * For i = 2, we can apply operations on A_1 and A_3, the final states will be 1100110; * For i β‰₯ 3, we can apply operations on A_1, A_2 and A_3, the final states will be 1111111. In the second example: * For i ≀ 6, we can just apply one operation on A_2, the final states will be 11111101; * For i β‰₯ 7, we can apply operations on A_1, A_3, A_4, A_6, the final states will be 11111111.
from sys import stdin input = stdin.readline n , k = [int(i) for i in input().split()] pairs = [i + k for i in range(k)] + [i for i in range(k)] initial_condition = list(map(lambda x: x == '1',input().strip())) data = [i for i in range(2*k)] constrain = [-1] * (2*k) h = [0] * (2*k) L = [1] * k + [0] * k dp1 = [-1 for i in range(n)] dp2 = [-1 for i in range(n)] for i in range(k): input() inp = [int(j) for j in input().split()] for s in inp: if dp1[s-1] == -1:dp1[s-1] = i else:dp2[s-1] = i pfsums = 0 ans = [] def remove_pfsum(s1): global pfsums if constrain[s1] == 1: pfsums -= L[s1] elif constrain[pairs[s1]] == 1: pfsums -= L[pairs[s1]] else: pfsums -= min(L[s1],L[pairs[s1]]) def sh(i): while i != data[i]: i = data[i] return i def upd_pfsum(s1): global pfsums if constrain[s1] == 1: pfsums += L[s1] elif constrain[pairs[s1]] == 1: pfsums += L[pairs[s1]] else: pfsums += min(L[s1],L[pairs[s1]]) def ms(i,j): i = sh(i) ; j = sh(j) cons = max(constrain[i],constrain[j]) if h[i] < h[j]: data[i] = j L[j] += L[i] constrain[j] = cons return j else: data[j] = i if h[i] == h[j]: h[i] += 1 L[i] += L[j] constrain[i] = cons return i for i in range(n): if dp1[i] == -1 and dp2[i] == -1: pass elif dp2[i] == -1: s1 = sh(dp1[i]) remove_pfsum(s1) constrain[s1] = 0 if initial_condition[i] else 1 constrain[pairs[s1]] = 1 if initial_condition[i] else 0 upd_pfsum(s1) else: s1 = sh(dp1[i]) ; s2 = sh(dp2[i]) if s1 == s2 or pairs[s1] == s2: pass else: remove_pfsum(s1) remove_pfsum(s2) if initial_condition[i]: new_s1 = ms(s1,s2) new_s2 = ms(pairs[s1],pairs[s2]) else: new_s1 = ms(s1,pairs[s2]) new_s2 = ms(pairs[s1],s2) pairs[new_s1] = new_s2 pairs[new_s2] = new_s1 upd_pfsum(new_s1) ans.append(pfsums) for i in ans: print(i)
{ "input": [ "5 3\n00011\n3\n1 2 3\n1\n4\n3\n3 4 5\n", "8 6\n00110011\n3\n1 3 8\n5\n1 2 5 6 7\n2\n6 8\n2\n3 5\n2\n4 7\n1\n2\n", "19 5\n1001001001100000110\n2\n2 3\n2\n5 6\n2\n8 9\n5\n12 13 14 15 16\n1\n19\n", "7 3\n0011100\n3\n1 4 6\n3\n3 4 7\n2\n2 3\n", "1 1\n1\n1\n1\n", "5 3\n00011\n3\n1 2 3\n1\n4\n3\n2 4 5\n", "1 1\n0\n1\n1\n", "1 0\n1\n1\n1\n", "8 6\n00100011\n3\n1 3 8\n5\n1 2 5 6 7\n2\n6 8\n2\n3 5\n2\n4 7\n1\n2\n", "5 3\n00011\n3\n1 2 3\n2\n4\n3\n2 4 5\n", "5 3\n00011\n3\n1 2 3\n1\n4\n3\n3 4 2\n", "5 3\n00011\n3\n1 2 3\n2\n4\n3\n1 4 5\n", "5 3\n00011\n3\n1 2 3\n1\n4\n2\n2 4 5\n", "5 3\n00011\n3\n1 2 3\n2\n2\n3\n2 4 5\n", "5 1\n00011\n3\n1 2 3\n2\n4\n3\n1 4 5\n", "5 3\n00011\n3\n1 2 3\n2\n2\n3\n0 4 5\n", "5 3\n00011\n3\n1 2 3\n2\n4\n3\n2 1 5\n", "5 1\n00011\n3\n1 2 3\n2\n4\n6\n1 4 5\n", "5 1\n00011\n3\n1 2 3\n2\n2\n3\n0 4 5\n", "1 0\n1\n1\n2\n", "5 1\n00011\n3\n1 2 3\n2\n4\n6\n1 4 4\n", "5 1\n00011\n3\n1 2 3\n4\n2\n3\n0 4 5\n", "5 1\n00011\n3\n1 2 3\n4\n1\n3\n0 4 5\n", "5 3\n00011\n3\n1 2 3\n1\n4\n0\n3 4 5\n", "5 1\n00011\n3\n1 2 3\n2\n4\n3\n2 4 5\n", "5 1\n00011\n3\n1 2 3\n2\n4\n3\n2 4 9\n", "1 0\n1\n1\n0\n", "5 3\n00011\n3\n1 2 3\n2\n4\n3\n2 1 2\n", "5 1\n00011\n3\n1 2 3\n2\n4\n6\n1 4 10\n", "1 0\n1\n1\n4\n", "5 1\n00011\n3\n1 2 3\n4\n2\n6\n0 4 5\n", "5 3\n00011\n3\n1 2 3\n1\n4\n0\n5 4 5\n", "5 1\n00011\n3\n1 2 3\n2\n4\n6\n2 4 9\n", "1 0\n1\n0\n0\n", "5 3\n00011\n3\n1 2 3\n2\n4\n4\n2 1 2\n", "5 1\n00011\n3\n1 2 3\n4\n2\n5\n0 4 5\n", "5 3\n00011\n3\n1 2 3\n1\n4\n0\n5 5 5\n", "5 1\n00011\n3\n1 2 3\n2\n4\n6\n2 0 9\n", "1 0\n1\n0\n-1\n", "5 1\n00011\n3\n1 2 3\n4\n2\n5\n0 4 0\n", "5 3\n00011\n3\n1 2 3\n1\n4\n0\n5 1 5\n", "5 1\n00011\n3\n1 2 3\n2\n4\n6\n0 0 9\n", "1 0\n1\n-1\n-1\n", "5 1\n00011\n3\n1 2 3\n5\n2\n5\n0 4 0\n", "5 1\n00011\n3\n1 2 3\n5\n2\n7\n0 4 0\n", "5 1\n00011\n3\n1 2 3\n5\n2\n7\n0 4 -1\n", "5 2\n00011\n3\n1 2 3\n1\n4\n3\n2 4 5\n", "5 1\n00011\n3\n1 2 3\n2\n4\n3\n1 8 5\n", "5 1\n00011\n3\n1 2 3\n2\n2\n3\n0 8 5\n", "5 1\n00011\n3\n1 2 3\n4\n4\n3\n0 4 5\n", "5 3\n00011\n3\n1 2 3\n1\n1\n0\n3 4 5\n", "5 1\n00011\n3\n1 2 3\n2\n6\n3\n2 4 9\n", "5 1\n00011\n3\n1 2 3\n2\n4\n6\n1 5 10\n", "5 3\n00011\n3\n1 2 3\n1\n1\n0\n5 5 5\n", "5 1\n00011\n3\n1 2 3\n2\n4\n6\n2 0 6\n", "5 1\n00011\n3\n1 2 3\n2\n3\n6\n0 0 9\n", "1 0\n1\n-1\n-2\n", "5 1\n00011\n3\n1 2 3\n5\n2\n6\n0 4 0\n" ], "output": [ "1\n1\n1\n1\n1\n", "1\n1\n1\n1\n1\n1\n4\n4\n", "0\n1\n1\n1\n2\n2\n2\n3\n3\n3\n3\n4\n4\n4\n4\n4\n4\n4\n5\n", "1\n2\n3\n3\n3\n3\n3\n", "0\n", "1\n1\n1\n1\n1\n", "1\n", "0\n", "1\n1\n1\n2\n2\n2\n2\n2\n", "1\n1\n1\n1\n1\n", "1\n1\n1\n1\n1\n", "1\n1\n1\n1\n1\n", "1\n1\n1\n1\n1\n", "1\n1\n1\n1\n1\n", "1\n1\n1\n1\n1\n", "1\n1\n1\n1\n1\n", "1\n1\n1\n1\n1\n", "1\n1\n1\n1\n1\n", "1\n1\n1\n1\n1\n", "0\n", "1\n1\n1\n1\n1\n", "1\n1\n1\n1\n1\n", "1\n1\n1\n1\n1\n", "1\n1\n1\n1\n1\n", "1\n1\n1\n1\n1\n", "1\n1\n1\n1\n1\n", "0\n", "1\n1\n1\n1\n1\n", "1\n1\n1\n1\n1\n", "0\n", "1\n1\n1\n1\n1\n", "1\n1\n1\n1\n1\n", "1\n1\n1\n1\n1\n", "0\n", "1\n1\n1\n1\n1\n", "1\n1\n1\n1\n1\n", "1\n1\n1\n1\n1\n", "1\n1\n1\n1\n1\n", "0\n", "1\n1\n1\n1\n1\n", "1\n1\n1\n1\n1\n", "1\n1\n1\n1\n1\n", "0\n", "1\n1\n1\n1\n1\n", "1\n1\n1\n1\n1\n", "1\n1\n1\n1\n1\n", "1\n1\n1\n1\n1\n", "1\n1\n1\n1\n1\n", "1\n1\n1\n1\n1\n", "1\n1\n1\n1\n1\n", "1\n1\n1\n1\n1\n", "1\n1\n1\n1\n1\n", "1\n1\n1\n1\n1\n", "1\n1\n1\n1\n1\n", "1\n1\n1\n1\n1\n", "1\n1\n1\n1\n1\n", "0\n", "1\n1\n1\n1\n1\n" ] }
2CODEFORCES
Below is a problem description that describes the problem. Write code in Python that appropriately solves the problem. ### Description: There are n lamps on a line, numbered from 1 to n. Each one has an initial state off (0) or on (1). You're given k subsets A_1, …, A_k of \{1, 2, ..., n\}, such that the intersection of any three subsets is empty. In other words, for all 1 ≀ i_1 < i_2 < i_3 ≀ k, A_{i_1} ∩ A_{i_2} ∩ A_{i_3} = βˆ…. In one operation, you can choose one of these k subsets and switch the state of all lamps in it. It is guaranteed that, with the given subsets, it's possible to make all lamps be simultaneously on using this type of operation. Let m_i be the minimum number of operations you have to do in order to make the i first lamps be simultaneously on. Note that there is no condition upon the state of other lamps (between i+1 and n), they can be either off or on. You have to compute m_i for all 1 ≀ i ≀ n. Input The first line contains two integers n and k (1 ≀ n, k ≀ 3 β‹… 10^5). The second line contains a binary string of length n, representing the initial state of each lamp (the lamp i is off if s_i = 0, on if s_i = 1). The description of each one of the k subsets follows, in the following format: The first line of the description contains a single integer c (1 ≀ c ≀ n) β€” the number of elements in the subset. The second line of the description contains c distinct integers x_1, …, x_c (1 ≀ x_i ≀ n) β€” the elements of the subset. It is guaranteed that: * The intersection of any three subsets is empty; * It's possible to make all lamps be simultaneously on using some operations. Output You must output n lines. The i-th line should contain a single integer m_i β€” the minimum number of operations required to make the lamps 1 to i be simultaneously on. Examples Input 7 3 0011100 3 1 4 6 3 3 4 7 2 2 3 Output 1 2 3 3 3 3 3 Input 8 6 00110011 3 1 3 8 5 1 2 5 6 7 2 6 8 2 3 5 2 4 7 1 2 Output 1 1 1 1 1 1 4 4 Input 5 3 00011 3 1 2 3 1 4 3 3 4 5 Output 1 1 1 1 1 Input 19 5 1001001001100000110 2 2 3 2 5 6 2 8 9 5 12 13 14 15 16 1 19 Output 0 1 1 1 2 2 2 3 3 3 3 4 4 4 4 4 4 4 5 Note In the first example: * For i = 1, we can just apply one operation on A_1, the final states will be 1010110; * For i = 2, we can apply operations on A_1 and A_3, the final states will be 1100110; * For i β‰₯ 3, we can apply operations on A_1, A_2 and A_3, the final states will be 1111111. In the second example: * For i ≀ 6, we can just apply one operation on A_2, the final states will be 11111101; * For i β‰₯ 7, we can apply operations on A_1, A_3, A_4, A_6, the final states will be 11111111. ### Input: 5 3 00011 3 1 2 3 1 4 3 3 4 5 ### Output: 1 1 1 1 1 ### Input: 8 6 00110011 3 1 3 8 5 1 2 5 6 7 2 6 8 2 3 5 2 4 7 1 2 ### Output: 1 1 1 1 1 1 4 4 ### Code: from sys import stdin input = stdin.readline n , k = [int(i) for i in input().split()] pairs = [i + k for i in range(k)] + [i for i in range(k)] initial_condition = list(map(lambda x: x == '1',input().strip())) data = [i for i in range(2*k)] constrain = [-1] * (2*k) h = [0] * (2*k) L = [1] * k + [0] * k dp1 = [-1 for i in range(n)] dp2 = [-1 for i in range(n)] for i in range(k): input() inp = [int(j) for j in input().split()] for s in inp: if dp1[s-1] == -1:dp1[s-1] = i else:dp2[s-1] = i pfsums = 0 ans = [] def remove_pfsum(s1): global pfsums if constrain[s1] == 1: pfsums -= L[s1] elif constrain[pairs[s1]] == 1: pfsums -= L[pairs[s1]] else: pfsums -= min(L[s1],L[pairs[s1]]) def sh(i): while i != data[i]: i = data[i] return i def upd_pfsum(s1): global pfsums if constrain[s1] == 1: pfsums += L[s1] elif constrain[pairs[s1]] == 1: pfsums += L[pairs[s1]] else: pfsums += min(L[s1],L[pairs[s1]]) def ms(i,j): i = sh(i) ; j = sh(j) cons = max(constrain[i],constrain[j]) if h[i] < h[j]: data[i] = j L[j] += L[i] constrain[j] = cons return j else: data[j] = i if h[i] == h[j]: h[i] += 1 L[i] += L[j] constrain[i] = cons return i for i in range(n): if dp1[i] == -1 and dp2[i] == -1: pass elif dp2[i] == -1: s1 = sh(dp1[i]) remove_pfsum(s1) constrain[s1] = 0 if initial_condition[i] else 1 constrain[pairs[s1]] = 1 if initial_condition[i] else 0 upd_pfsum(s1) else: s1 = sh(dp1[i]) ; s2 = sh(dp2[i]) if s1 == s2 or pairs[s1] == s2: pass else: remove_pfsum(s1) remove_pfsum(s2) if initial_condition[i]: new_s1 = ms(s1,s2) new_s2 = ms(pairs[s1],pairs[s2]) else: new_s1 = ms(s1,pairs[s2]) new_s2 = ms(pairs[s1],s2) pairs[new_s1] = new_s2 pairs[new_s2] = new_s1 upd_pfsum(new_s1) ans.append(pfsums) for i in ans: print(i)
1311_F. Moving Points_45
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t β‹… v_i. Consider two points i and j. Let d(i, j) be the minimum possible distance between these two points over any possible moments of time (even non-integer). It means that if two points i and j coincide at some moment, the value d(i, j) will be 0. Your task is to calculate the value βˆ‘_{1 ≀ i < j ≀ n} d(i, j) (the sum of minimum distances over all pairs of points). Input The first line of the input contains one integer n (2 ≀ n ≀ 2 β‹… 10^5) β€” the number of points. The second line of the input contains n integers x_1, x_2, ..., x_n (1 ≀ x_i ≀ 10^8), where x_i is the initial coordinate of the i-th point. It is guaranteed that all x_i are distinct. The third line of the input contains n integers v_1, v_2, ..., v_n (-10^8 ≀ v_i ≀ 10^8), where v_i is the speed of the i-th point. Output Print one integer β€” the value βˆ‘_{1 ≀ i < j ≀ n} d(i, j) (the sum of minimum distances over all pairs of points). Examples Input 3 1 3 2 -100 2 3 Output 3 Input 5 2 1 4 3 5 2 2 2 3 4 Output 19 Input 2 2 1 -3 0 Output 0
import bisect def getsum(tree , i): s = 0 i += 1 while i>0: s += tree[i] i -= i & (-i) return s def updatebit(tree , n , i , v): i+= 1 while i <= n: tree[i] += v i += i & (-i) n = int(input()) x = list(map(int , input().split())) v = list(map(int , input().split())) p = [[x[i] , v[i]] for i in range(len(x))] vs = sorted(list(set(v))) p = sorted(p , key = lambda i : i[0]) l = len(vs) cnt = [0]*(l+1) xs = [0]*(l+1) ans = 0 for pnt in p: pos = bisect.bisect_left(vs , pnt[1]) ans += getsum(cnt , pos) * pnt[0] - getsum(xs , pos) updatebit(cnt , l , pos , 1) updatebit(xs , l , pos , pnt[0]) print(ans)
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n", "3\n1 3 2\n-100 2 6\n", "2\n2 1\n-4 0\n", "2\n0 1\n-4 0\n", "2\n0 2\n-4 0\n", "3\n1 5 2\n-167 2 6\n", "3\n1 3 2\n-75 1 0\n", "3\n1 7 2\n-255 0 6\n", "3\n1 3 8\n-75 1 0\n", "3\n1 3 8\n-75 1 1\n", "3\n0 4 8\n-75 1 1\n", "3\n0 4 8\n-75 1 0\n", "5\n2 1 4 3 5\n0 2 2 3 4\n", "3\n1 3 4\n-109 2 6\n", "3\n1 3 2\n-167 2 6\n", "3\n1 3 2\n-172 2 6\n", "3\n1 3 2\n-109 2 6\n", "3\n1 3 2\n-75 2 3\n", "2\n2 1\n-5 0\n", "3\n1 3 2\n-100 1 6\n", "2\n2 1\n-4 1\n", "3\n1 3 2\n-11 2 6\n", "2\n0 2\n-7 0\n", "3\n1 3 2\n-109 3 6\n", "3\n1 3 2\n-75 1 3\n", "2\n2 1\n-5 -1\n", "3\n1 3 2\n-189 1 6\n", "2\n0 1\n-4 1\n", "3\n1 5 2\n-255 2 6\n", "3\n0 3 2\n-11 2 6\n", "2\n0 2\n-7 1\n", "3\n1 3 2\n-75 1 2\n", "2\n0 2\n-4 1\n", "3\n1 5 2\n-255 0 6\n", "2\n0 2\n-7 2\n", "2\n0 1\n-7 1\n", "2\n0 2\n-10 2\n", "3\n1 3 4\n-75 1 0\n", "3\n1 7 2\n-215 0 6\n", "2\n1 2\n-10 2\n", "3\n1 7 2\n-215 0 9\n", "2\n1 3\n-10 2\n", "2\n1 3\n-5 2\n", "3\n1 4 8\n-75 1 1\n", "2\n2 3\n-5 2\n", "2\n2 3\n-10 2\n", "3\n1 3 2\n-100 2 10\n", "2\n1 2\n-4 0\n", "3\n1 3 2\n-167 0 6\n", "3\n1 3 2\n-172 4 6\n", "2\n0 4\n-4 0\n", "3\n1 3 2\n-82 2 3\n", "2\n3 1\n-5 -1\n", "3\n1 5 2\n-167 2 9\n", "3\n1 6 2\n-11 2 6\n", "2\n1 2\n-7 0\n", "3\n1 3 4\n-109 3 6\n" ], "output": [ "3\n", "0\n", "19\n", "3\n", "0\n", "1\n", "2\n", "5\n", "4\n", "7\n", "9\n", "14\n", "16\n", "12\n", "18\n", "6\n", "3\n", "3\n", "3\n", "3\n", "0\n", "3\n", "0\n", "3\n", "2\n", "3\n", "3\n", "0\n", "3\n", "1\n", "5\n", "5\n", "2\n", "3\n", "2\n", "5\n", "2\n", "1\n", "2\n", "5\n", "7\n", "1\n", "7\n", "2\n", "2\n", "14\n", "1\n", "1\n", "3\n", "1\n", "3\n", "3\n", "4\n", "3\n", "0\n", "5\n", "6\n", "1\n", "6\n" ] }
2CODEFORCES
Below is a problem description that describes the problem. Write code in Python that appropriately solves the problem. ### Description: There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t β‹… v_i. Consider two points i and j. Let d(i, j) be the minimum possible distance between these two points over any possible moments of time (even non-integer). It means that if two points i and j coincide at some moment, the value d(i, j) will be 0. Your task is to calculate the value βˆ‘_{1 ≀ i < j ≀ n} d(i, j) (the sum of minimum distances over all pairs of points). Input The first line of the input contains one integer n (2 ≀ n ≀ 2 β‹… 10^5) β€” the number of points. The second line of the input contains n integers x_1, x_2, ..., x_n (1 ≀ x_i ≀ 10^8), where x_i is the initial coordinate of the i-th point. It is guaranteed that all x_i are distinct. The third line of the input contains n integers v_1, v_2, ..., v_n (-10^8 ≀ v_i ≀ 10^8), where v_i is the speed of the i-th point. Output Print one integer β€” the value βˆ‘_{1 ≀ i < j ≀ n} d(i, j) (the sum of minimum distances over all pairs of points). Examples Input 3 1 3 2 -100 2 3 Output 3 Input 5 2 1 4 3 5 2 2 2 3 4 Output 19 Input 2 2 1 -3 0 Output 0 ### Input: 3 1 3 2 -100 2 3 ### Output: 3 ### Input: 2 2 1 -3 0 ### Output: 0 ### Code: import bisect def getsum(tree , i): s = 0 i += 1 while i>0: s += tree[i] i -= i & (-i) return s def updatebit(tree , n , i , v): i+= 1 while i <= n: tree[i] += v i += i & (-i) n = int(input()) x = list(map(int , input().split())) v = list(map(int , input().split())) p = [[x[i] , v[i]] for i in range(len(x))] vs = sorted(list(set(v))) p = sorted(p , key = lambda i : i[0]) l = len(vs) cnt = [0]*(l+1) xs = [0]*(l+1) ans = 0 for pnt in p: pos = bisect.bisect_left(vs , pnt[1]) ans += getsum(cnt , pos) * pnt[0] - getsum(xs , pos) updatebit(cnt , l , pos , 1) updatebit(xs , l , pos , pnt[0]) print(ans)
1334_D. Minimum Euler Cycle_49
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of n(n - 1) + 1 vertices v_1, v_2, v_3, ..., v_{n(n - 1) - 1}, v_{n(n - 1)}, v_{n(n - 1) + 1} = v_1 β€” a visiting order, where each (v_i, v_{i + 1}) occurs exactly once. Find the lexicographically smallest such cycle. It's not hard to prove that the cycle always exists. Since the answer can be too large print its [l, r] segment, in other words, v_l, v_{l + 1}, ..., v_r. Input The first line contains the single integer T (1 ≀ T ≀ 100) β€” the number of test cases. Next T lines contain test cases β€” one per line. The first and only line of each test case contains three integers n, l and r (2 ≀ n ≀ 10^5, 1 ≀ l ≀ r ≀ n(n - 1) + 1, r - l + 1 ≀ 10^5) β€” the number of vertices in K_n, and segment of the cycle to print. It's guaranteed that the total sum of n doesn't exceed 10^5 and the total sum of r - l + 1 doesn't exceed 10^5. Output For each test case print the segment v_l, v_{l + 1}, ..., v_r of the lexicographically smallest cycle that visits every edge exactly once. Example Input 3 2 1 3 3 3 6 99995 9998900031 9998900031 Output 1 2 1 1 3 2 3 1 Note In the second test case, the lexicographically minimum cycle looks like: 1, 2, 1, 3, 2, 3, 1. In the third test case, it's quite obvious that the cycle should start and end in vertex 1.
# -*- coding:utf-8 -*- """ created by shuangquan.huang at 2020/7/1 """ import collections import time import os import sys import bisect import heapq from typing import List def solve(n, l, r): # 1, 2, 1, 3, ..., 1, n # 2, 3, 2, 4, ..., 2, n # ... # n-1, n # 1 lo, hi = 1, n while lo <= hi: k = (lo + hi) // 2 s = k * (2*n-1-k) if s < l: lo = k + 1 else: hi = k - 1 k = lo s = k * (2*n-1-k) b = k # [b, b+1, b, b+2, ..., b, n] row = [] for i in range(b+1, n+1): row.append(b) row.append(i) ans = row[l-s-1:] d = r-l+1 if len(ans) >= d: return ans[:d] while len(ans) < d: b += 1 row = [] for i in range(b + 1, n + 1): row.append(b) row.append(i) if not row: break ans += row ans.append(1) # print(ans[:d]) return ans[:d] if __name__ == '__main__': T = int(input()) ans = [] for ti in range(T): N, L, R = map(int, input().split()) ans.append(solve(N, L, R)) print('\n'.join([' '.join(map(str, v)) for v in ans]))
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n", "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n", "1\n3 1 2\n", "1\n25 30 500\n", "1\n5 4 7\n", "3\n2 1 3\n3 4 6\n99995 9998900031 9998900031\n", "1\n25 30 429\n", "1\n5 1 7\n", "1\n5 1 9\n", "1\n10 1 9\n", "1\n3 2 3\n", "1\n29 30 295\n", "1\n4 4 13\n", "5\n3 7 7\n4 13 13\n5 13 21\n6 31 31\n7 42 43\n", "1\n4 4 4\n", "1\n41 30 500\n", "1\n25 39 429\n", "1\n4 1 7\n", "1\n5 1 12\n", "1\n29 6 295\n", "5\n3 7 7\n4 13 13\n5 13 21\n6 31 31\n7 26 43\n", "1\n41 30 366\n", "1\n46 39 429\n", "1\n5 1 14\n", "1\n29 8 295\n", "1\n8 4 5\n", "1\n76 39 429\n", "1\n6 1 11\n", "1\n27 8 295\n", "1\n76 39 574\n", "1\n27 5 295\n", "1\n6 1 5\n", "1\n76 39 665\n", "1\n27 5 477\n", "1\n76 46 665\n", "1\n27 1 477\n", "1\n76 2 665\n", "1\n27 1 92\n", "1\n76 4 665\n", "1\n76 8 665\n", "1\n132 8 665\n", "1\n132 15 665\n", "1\n132 15 33\n", "1\n132 21 33\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 2 3\n2 1 3\n", "1\n25 42 295\n", "1\n5 1 13\n", "3\n3 1 3\n3 4 7\n99995 9998900031 9998900031\n", "1\n25 48 429\n", "1\n5 2 7\n", "1\n4 1 9\n", "1\n10 1 14\n", "1\n29 30 444\n", "5\n3 7 7\n4 13 13\n6 13 21\n6 31 31\n7 42 43\n", "1\n50 30 500\n", "3\n3 1 3\n3 2 6\n99995 9998900031 9998900031\n", "1\n40 6 295\n", "5\n3 7 7\n4 13 13\n5 13 21\n6 31 31\n8 26 43\n", "1\n28 30 366\n", "1\n46 60 429\n", "1\n5 2 14\n", "1\n150 39 429\n", "1\n27 8 134\n", "1\n50 39 574\n", "1\n30 5 295\n", "1\n76 36 665\n", "1\n27 5 597\n", "1\n76 46 112\n", "1\n27 2 477\n", "1\n21 2 5\n", "1\n21 1 92\n", "1\n76 4 1263\n", "1\n113 8 665\n", "1\n132 8 1257\n", "1\n119 15 665\n", "1\n132 15 41\n", "1\n25 42 147\n", "1\n5 2 13\n", "1\n44 30 444\n", "3\n3 1 3\n3 4 6\n99995 9998900031 9998900031\n", "1\n8 4 4\n", "1\n6 1 7\n", "1\n6 4 5\n", "1\n11 1 5\n", "1\n21 1 5\n", "1\n4 2 3\n", "1\n6 4 4\n", "1\n8 4 7\n", "1\n8 1 5\n", "1\n20 1 5\n", "1\n151 21 33\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n", "2 1 \n", "1 \n", "1 \n", "1 2 1 \n1 2 1 \n1 2 1 \n1 2 1 \n1 2 1 \n1 2 1 \n1 2 1 \n1 2 1 \n1 2 1 \n1 2 1 \n", "1 \n", "16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 25 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19 3 20 3 21 3 22 3 23 3 24 3 25 4 5 4 6 4 7 4 8 4 9 4 10 4 11 4 12 4 13 4 14 4 15 4 16 4 17 4 18 4 19 4 20 4 21 4 22 4 23 4 24 4 25 5 6 5 7 5 8 5 9 5 10 5 11 5 12 5 13 5 14 5 15 5 16 5 17 5 18 5 19 5 20 5 21 5 22 5 23 5 24 5 25 6 7 6 8 6 9 6 10 6 11 6 12 6 13 6 14 6 15 6 16 6 17 6 18 6 19 6 20 6 21 6 22 6 23 6 24 6 25 7 8 7 9 7 10 7 11 7 12 7 13 7 14 7 15 7 16 7 17 7 18 7 19 7 20 7 21 7 22 7 23 7 24 7 25 8 \n", "4 1 \n", "1 \n1 \n1 \n1 \n7 1 \n", "3 \n", "1 2\n", "16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 25 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19 3 20 3 21 3 22 3 23 3 24 3 25 4 5 4 6 4 7 4 8 4 9 4 10 4 11 4 12 4 13 4 14 4 15 4 16 4 17 4 18 4 19 4 20 4 21 4 22 4 23 4 24 4 25 5 6 5 7 5 8 5 9 5 10 5 11 5 12 5 13 5 14 5 15 5 16 5 17 5 18 5 19 5 20 5 21 5 22 5 23 5 24 5 25 6 7 6 8 6 9 6 10 6 11 6 12 6 13 6 14 6 15 6 16 6 17 6 18 6 19 6 20 6 21 6 22 6 23 6 24 6 25 7 8 7 9 7 10 7 11 7 12 7 13 7 14 7 15 7 16 7 17 7 18 7 19 7 20 7 21 7 22 7 23 7 24 7 25 8 9 8 10 8 11 8 12 8 13 8 14 8 15 8 16 8 17 8 18 8 19 8 20 8 21 8 22 8 23 8 24 8 25 9 10 9 11 9 12 9 13 9 14 9 15 9 16 9 17 9 18 9 19 9 20 9 21 9 22 9 23 9 24 9 25 10 11 10 12 10 13 10 14 10 15 10 16 10 17 10 18 10 19 10 20 10 21 10 22 10 23 10 24 10 25 11 12 11 13 11 14 11 15 11 16 11 17 11 18 11 19 11 20 11 21 11 22 11 23 11 24 11 25 12 13 12 14 12 15 12 16 12 17 12 18 12 19 12 20 12 21 12 22 12 23 12 24 12 25 13 14 13 15 13 16 13 17 13 18 13 19 13 20 13 21 13 22 13 23 13 24 13 25 14 15 14 16 14 17 14 18 14 19 14 20 14 21 14 22 14 23 14 24 14 25 15 16 15 17 15 18 15 19 15 20\n", "3 1 4 1\n", "1 2 1\n3 2 3\n1\n", "16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 25 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19 3 20 3 21 3 22 3 23 3 24 3 25 4 5 4 6 4 7 4 8 4 9 4 10 4 11 4 12 4 13 4 14 4 15 4 16 4 17 4 18 4 19 4 20 4 21 4 22 4 23 4 24 4 25 5 6 5 7 5 8 5 9 5 10 5 11 5 12 5 13 5 14 5 15 5 16 5 17 5 18 5 19 5 20 5 21 5 22 5 23 5 24 5 25 6 7 6 8 6 9 6 10 6 11 6 12 6 13 6 14 6 15 6 16 6 17 6 18 6 19 6 20 6 21 6 22 6 23 6 24 6 25 7 8 7 9 7 10 7 11 7 12 7 13 7 14 7 15 7 16 7 17 7 18 7 19 7 20 7 21 7 22 7 23 7 24 7 25 8 9 8 10 8 11 8 12 8 13 8 14 8 15 8 16 8 17 8 18 8 19 8 20 8 21 8 22 8 23 8 24 8 25 9 10 9 11 9 12 9 13 9 14 9 15 9 16 9 17 9 18 9 19 9 20 9 21 9 22 9 23 9 24 9 25 10 11 10 12 10 13 10 14 10 15 10 16 10 17 10 18 10 19 10 20 10 21 10 22 10 23 10 24 10 25 11 12 11 13 11 14 11 15 11 16 11 17 11 18 11 19 11 20 11 21 11 22 11 23 11 24 11 25 12 13 12 14 12 15 12 16 12 17 12\n", "1 2 1 3 1 4 1\n", "1 2 1 3 1 4 1 5 2\n", "1 2 1 3 1 4 1 5 1\n", "2 1\n", "16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 25 2 26 2 27 2 28 2 29 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19 3 20 3 21 3 22 3 23 3 24 3 25 3 26 3 27 3 28 3 29 4 5 4 6 4 7 4 8 4 9 4 10 4 11 4 12 4 13 4 14 4 15 4 16 4 17 4 18 4 19 4 20 4 21 4 22 4 23 4 24 4 25 4 26 4 27 4 28 4 29 5 6 5 7 5 8 5 9 5 10 5 11 5 12 5 13 5 14 5 15 5 16 5 17 5 18 5 19 5 20 5 21 5 22 5 23 5 24 5 25 5 26 5 27 5 28 5 29 6 7 6 8 6 9 6 10 6 11 6 12 6 13 6 14 6 15 6 16 6 17 6 18 6 19 6 20 6 21 6 22 6 23 6\n", "3 1 4 2 3 2 4 3 4 1\n", "1\n1\n2 5 3 4 3 5 4 5 1\n1\n7 1\n", "3\n", "16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 25 2 26 2 27 2 28 2 29 2 30 2 31 2 32 2 33 2 34 2 35 2 36 2 37 2 38 2 39 2 40 2 41 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19 3 20 3 21 3 22 3 23 3 24 3 25 3 26 3 27 3 28 3 29 3 30 3 31 3 32 3 33 3 34 3 35 3 36 3 37 3 38 3 39 3 40 3 41 4 5 4 6 4 7 4 8 4 9 4 10 4 11 4 12 4 13 4 14 4 15 4 16 4 17 4 18 4 19 4 20 4 21 4 22 4 23 4 24 4 25 4 26 4 27 4 28 4 29 4 30 4 31 4 32 4 33 4 34 4 35 4 36 4 37 4 38 4 39 4 40 4 41 5 6 5 7 5 8 5 9 5 10 5 11 5 12 5 13 5 14 5 15 5 16 5 17 5 18 5 19 5 20 5 21 5 22 5 23 5 24 5 25 5 26 5 27 5 28 5 29 5 30 5 31 5 32 5 33 5 34 5 35 5 36 5 37 5 38 5 39 5 40 5 41 6 7 6 8 6 9 6 10 6 11 6 12 6 13 6 14 6 15 6 16 6 17 6 18 6 19 6 20 6 21 6 22 6 23 6 24 6 25 6 26 6 27 6 28 6 29 6 30 6 31 6 32 6 33 6 34 6 35 6 36 6 37 6 38 6 39 6 40 6 41 7 8 7 9 7 10 7 11 7 12 7 13 7 14 7 15 7 16 7 17 7 18 7 19 7 20 7 21 7 22 7 23 7 24 7 25 7 26 7 27 7 28 7 29 7 30 7 31 7 32\n", "1 21 1 22 1 23 1 24 1 25 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 25 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19 3 20 3 21 3 22 3 23 3 24 3 25 4 5 4 6 4 7 4 8 4 9 4 10 4 11 4 12 4 13 4 14 4 15 4 16 4 17 4 18 4 19 4 20 4 21 4 22 4 23 4 24 4 25 5 6 5 7 5 8 5 9 5 10 5 11 5 12 5 13 5 14 5 15 5 16 5 17 5 18 5 19 5 20 5 21 5 22 5 23 5 24 5 25 6 7 6 8 6 9 6 10 6 11 6 12 6 13 6 14 6 15 6 16 6 17 6 18 6 19 6 20 6 21 6 22 6 23 6 24 6 25 7 8 7 9 7 10 7 11 7 12 7 13 7 14 7 15 7 16 7 17 7 18 7 19 7 20 7 21 7 22 7 23 7 24 7 25 8 9 8 10 8 11 8 12 8 13 8 14 8 15 8 16 8 17 8 18 8 19 8 20 8 21 8 22 8 23 8 24 8 25 9 10 9 11 9 12 9 13 9 14 9 15 9 16 9 17 9 18 9 19 9 20 9 21 9 22 9 23 9 24 9 25 10 11 10 12 10 13 10 14 10 15 10 16 10 17 10 18 10 19 10 20 10 21 10 22 10 23 10 24 10 25 11 12 11 13 11 14 11 15 11 16 11 17 11 18 11 19 11 20 11 21 11 22 11 23 11 24 11 25 12 13 12 14 12 15 12 16 12 17 12\n", "1 2 1 3 1 4 2\n", "1 2 1 3 1 4 1 5 2 3 2 4\n", "4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 25 2 26 2 27 2 28 2 29 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19 3 20 3 21 3 22 3 23 3 24 3 25 3 26 3 27 3 28 3 29 4 5 4 6 4 7 4 8 4 9 4 10 4 11 4 12 4 13 4 14 4 15 4 16 4 17 4 18 4 19 4 20 4 21 4 22 4 23 4 24 4 25 4 26 4 27 4 28 4 29 5 6 5 7 5 8 5 9 5 10 5 11 5 12 5 13 5 14 5 15 5 16 5 17 5 18 5 19 5 20 5 21 5 22 5 23 5 24 5 25 5 26 5 27 5 28 5 29 6 7 6 8 6 9 6 10 6 11 6 12 6 13 6 14 6 15 6 16 6 17 6 18 6 19 6 20 6 21 6 22 6 23 6\n", "1\n1\n2 5 3 4 3 5 4 5 1\n1\n5 3 6 3 7 4 5 4 6 4 7 5 6 5 7 6 7 1\n", "16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 25 2 26 2 27 2 28 2 29 2 30 2 31 2 32 2 33 2 34 2 35 2 36 2 37 2 38 2 39 2 40 2 41 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19 3 20 3 21 3 22 3 23 3 24 3 25 3 26 3 27 3 28 3 29 3 30 3 31 3 32 3 33 3 34 3 35 3 36 3 37 3 38 3 39 3 40 3 41 4 5 4 6 4 7 4 8 4 9 4 10 4 11 4 12 4 13 4 14 4 15 4 16 4 17 4 18 4 19 4 20 4 21 4 22 4 23 4 24 4 25 4 26 4 27 4 28 4 29 4 30 4 31 4 32 4 33 4 34 4 35 4 36 4 37 4 38 4 39 4 40 4 41 5 6 5 7 5 8 5 9 5 10 5 11 5 12 5 13 5 14 5 15 5 16 5 17 5 18 5 19 5 20 5 21 5 22 5 23 5 24 5 25 5 26 5 27 5 28 5 29 5 30 5 31 5 32 5 33 5 34\n", "1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 25 2 26 2 27 2 28 2 29 2 30 2 31 2 32 2 33 2 34 2 35 2 36 2 37 2 38 2 39 2 40 2 41 2 42 2 43 2 44 2 45 2 46 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19 3 20 3 21 3 22 3 23 3 24 3 25 3 26 3 27 3 28 3 29 3 30 3 31 3 32 3 33 3 34 3 35 3 36 3 37 3 38 3 39 3 40 3 41 3 42 3 43 3 44 3 45 3 46 4 5 4 6 4 7 4 8 4 9 4 10 4 11 4 12 4 13 4 14 4 15 4 16 4 17 4 18 4 19 4 20 4 21 4 22 4 23 4 24 4 25 4 26 4 27 4 28 4 29 4 30 4 31 4 32 4 33 4 34 4 35 4 36 4 37 4 38 4 39 4 40 4 41 4 42 4 43 4 44 4 45 4 46 5 6 5 7 5 8 5 9 5 10 5 11 5 12 5 13 5 14 5 15 5 16 5 17 5 18 5 19 5 20 5 21 5 22 5 23 5 24 5 25 5 26 5 27 5 28 5 29 5 30 5 31 5 32 5 33 5 34 5 35 5 36 5 37 5 38 5 39 5 40 5 41 5 42 5 43 5 44 5 45 5\n", "1 2 1 3 1 4 1 5 2 3 2 4 2 5\n", "5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 25 2 26 2 27 2 28 2 29 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19 3 20 3 21 3 22 3 23 3 24 3 25 3 26 3 27 3 28 3 29 4 5 4 6 4 7 4 8 4 9 4 10 4 11 4 12 4 13 4 14 4 15 4 16 4 17 4 18 4 19 4 20 4 21 4 22 4 23 4 24 4 25 4 26 4 27 4 28 4 29 5 6 5 7 5 8 5 9 5 10 5 11 5 12 5 13 5 14 5 15 5 16 5 17 5 18 5 19 5 20 5 21 5 22 5 23 5 24 5 25 5 26 5 27 5 28 5 29 6 7 6 8 6 9 6 10 6 11 6 12 6 13 6 14 6 15 6 16 6 17 6 18 6 19 6 20 6 21 6 22 6 23 6\n", "3 1\n", "1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60 1 61 1 62 1 63 1 64 1 65 1 66 1 67 1 68 1 69 1 70 1 71 1 72 1 73 1 74 1 75 1 76 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 25 2 26 2 27 2 28 2 29 2 30 2 31 2 32 2 33 2 34 2 35 2 36 2 37 2 38 2 39 2 40 2 41 2 42 2 43 2 44 2 45 2 46 2 47 2 48 2 49 2 50 2 51 2 52 2 53 2 54 2 55 2 56 2 57 2 58 2 59 2 60 2 61 2 62 2 63 2 64 2 65 2 66 2 67 2 68 2 69 2 70 2 71 2 72 2 73 2 74 2 75 2 76 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19 3 20 3 21 3 22 3 23 3 24 3 25 3 26 3 27 3 28 3 29 3 30 3 31 3 32 3 33 3 34 3 35 3 36 3 37 3 38 3 39 3 40 3 41 3 42 3 43 3 44 3 45 3 46 3 47 3 48 3 49 3 50 3 51 3 52 3 53 3 54 3 55 3 56 3 57 3 58 3 59 3 60 3 61 3 62 3 63 3 64 3 65 3 66 3 67 3 68 3\n", "1 2 1 3 1 4 1 5 1 6 2\n", "5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 25 2 26 2 27 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19 3 20 3 21 3 22 3 23 3 24 3 25 3 26 3 27 4 5 4 6 4 7 4 8 4 9 4 10 4 11 4 12 4 13 4 14 4 15 4 16 4 17 4 18 4 19 4 20 4 21 4 22 4 23 4 24 4 25 4 26 4 27 5 6 5 7 5 8 5 9 5 10 5 11 5 12 5 13 5 14 5 15 5 16 5 17 5 18 5 19 5 20 5 21 5 22 5 23 5 24 5 25 5 26 5 27 6 7 6 8 6 9 6 10 6 11 6 12 6 13 6 14 6 15 6 16 6 17 6 18 6 19 6 20 6 21 6 22 6 23 6 24 6 25 6 26 6 27 7 8 7 9 7 10 7 11 7 12 7 13 7\n", "1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60 1 61 1 62 1 63 1 64 1 65 1 66 1 67 1 68 1 69 1 70 1 71 1 72 1 73 1 74 1 75 1 76 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 25 2 26 2 27 2 28 2 29 2 30 2 31 2 32 2 33 2 34 2 35 2 36 2 37 2 38 2 39 2 40 2 41 2 42 2 43 2 44 2 45 2 46 2 47 2 48 2 49 2 50 2 51 2 52 2 53 2 54 2 55 2 56 2 57 2 58 2 59 2 60 2 61 2 62 2 63 2 64 2 65 2 66 2 67 2 68 2 69 2 70 2 71 2 72 2 73 2 74 2 75 2 76 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19 3 20 3 21 3 22 3 23 3 24 3 25 3 26 3 27 3 28 3 29 3 30 3 31 3 32 3 33 3 34 3 35 3 36 3 37 3 38 3 39 3 40 3 41 3 42 3 43 3 44 3 45 3 46 3 47 3 48 3 49 3 50 3 51 3 52 3 53 3 54 3 55 3 56 3 57 3 58 3 59 3 60 3 61 3 62 3 63 3 64 3 65 3 66 3 67 3 68 3 69 3 70 3 71 3 72 3 73 3 74 3 75 3 76 4 5 4 6 4 7 4 8 4 9 4 10 4 11 4 12 4 13 4 14 4 15 4 16 4 17 4 18 4 19 4 20 4 21 4 22 4 23 4 24 4 25 4 26 4 27 4 28 4 29 4 30 4 31 4 32 4 33 4 34 4 35 4 36 4 37 4 38 4 39 4 40 4 41 4 42 4 43 4 44 4 45 4 46 4 47 4 48 4 49 4 50 4 51 4 52 4 53 4 54 4 55 4 56 4 57 4 58 4 59 4 60 4 61 4 62 4 63 4 64 4 65 4 66 4 67 4 68 4 69\n", "1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 25 2 26 2 27 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19 3 20 3 21 3 22 3 23 3 24 3 25 3 26 3 27 4 5 4 6 4 7 4 8 4 9 4 10 4 11 4 12 4 13 4 14 4 15 4 16 4 17 4 18 4 19 4 20 4 21 4 22 4 23 4 24 4 25 4 26 4 27 5 6 5 7 5 8 5 9 5 10 5 11 5 12 5 13 5 14 5 15 5 16 5 17 5 18 5 19 5 20 5 21 5 22 5 23 5 24 5 25 5 26 5 27 6 7 6 8 6 9 6 10 6 11 6 12 6 13 6 14 6 15 6 16 6 17 6 18 6 19 6 20 6 21 6 22 6 23 6 24 6 25 6 26 6 27 7 8 7 9 7 10 7 11 7 12 7 13 7\n", "1 2 1 3 1\n", "1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60 1 61 1 62 1 63 1 64 1 65 1 66 1 67 1 68 1 69 1 70 1 71 1 72 1 73 1 74 1 75 1 76 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 25 2 26 2 27 2 28 2 29 2 30 2 31 2 32 2 33 2 34 2 35 2 36 2 37 2 38 2 39 2 40 2 41 2 42 2 43 2 44 2 45 2 46 2 47 2 48 2 49 2 50 2 51 2 52 2 53 2 54 2 55 2 56 2 57 2 58 2 59 2 60 2 61 2 62 2 63 2 64 2 65 2 66 2 67 2 68 2 69 2 70 2 71 2 72 2 73 2 74 2 75 2 76 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19 3 20 3 21 3 22 3 23 3 24 3 25 3 26 3 27 3 28 3 29 3 30 3 31 3 32 3 33 3 34 3 35 3 36 3 37 3 38 3 39 3 40 3 41 3 42 3 43 3 44 3 45 3 46 3 47 3 48 3 49 3 50 3 51 3 52 3 53 3 54 3 55 3 56 3 57 3 58 3 59 3 60 3 61 3 62 3 63 3 64 3 65 3 66 3 67 3 68 3 69 3 70 3 71 3 72 3 73 3 74 3 75 3 76 4 5 4 6 4 7 4 8 4 9 4 10 4 11 4 12 4 13 4 14 4 15 4 16 4 17 4 18 4 19 4 20 4 21 4 22 4 23 4 24 4 25 4 26 4 27 4 28 4 29 4 30 4 31 4 32 4 33 4 34 4 35 4 36 4 37 4 38 4 39 4 40 4 41 4 42 4 43 4 44 4 45 4 46 4 47 4 48 4 49 4 50 4 51 4 52 4 53 4 54 4 55 4 56 4 57 4 58 4 59 4 60 4 61 4 62 4 63 4 64 4 65 4 66 4 67 4 68 4 69 4 70 4 71 4 72 4 73 4 74 4 75 4 76 5 6 5 7 5 8 5 9 5 10 5 11 5 12 5 13 5 14 5 15 5 16 5 17 5 18 5 19 5 20 5 21 5 22 5 23 5 24 5 25 5 26 5 27 5 28 5 29 5 30 5 31 5 32 5 33 5 34 5 35 5 36 5 37 5 38 5 39 5 40 5 41 5 42 5 43 5\n", "1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 25 2 26 2 27 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19 3 20 3 21 3 22 3 23 3 24 3 25 3 26 3 27 4 5 4 6 4 7 4 8 4 9 4 10 4 11 4 12 4 13 4 14 4 15 4 16 4 17 4 18 4 19 4 20 4 21 4 22 4 23 4 24 4 25 4 26 4 27 5 6 5 7 5 8 5 9 5 10 5 11 5 12 5 13 5 14 5 15 5 16 5 17 5 18 5 19 5 20 5 21 5 22 5 23 5 24 5 25 5 26 5 27 6 7 6 8 6 9 6 10 6 11 6 12 6 13 6 14 6 15 6 16 6 17 6 18 6 19 6 20 6 21 6 22 6 23 6 24 6 25 6 26 6 27 7 8 7 9 7 10 7 11 7 12 7 13 7 14 7 15 7 16 7 17 7 18 7 19 7 20 7 21 7 22 7 23 7 24 7 25 7 26 7 27 8 9 8 10 8 11 8 12 8 13 8 14 8 15 8 16 8 17 8 18 8 19 8 20 8 21 8 22 8 23 8 24 8 25 8 26 8 27 9 10 9 11 9 12 9 13 9 14 9 15 9 16 9 17 9 18 9 19 9 20 9 21 9 22 9 23 9 24 9 25 9 26 9 27 10 11 10 12 10 13 10 14 10 15 10 16 10 17 10 18 10 19 10 20 10 21 10 22 10 23 10 24 10 25 10 26 10 27 11 12 11 13 11 14 11 15 11 16 11 17 11 18 11 19 11 20 11 21 11 22 11 23 11 24 11 25 11 26 11 27 12 13 12 14 12 15 12 16 12 17 12 18 12 19 12\n", "24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60 1 61 1 62 1 63 1 64 1 65 1 66 1 67 1 68 1 69 1 70 1 71 1 72 1 73 1 74 1 75 1 76 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 25 2 26 2 27 2 28 2 29 2 30 2 31 2 32 2 33 2 34 2 35 2 36 2 37 2 38 2 39 2 40 2 41 2 42 2 43 2 44 2 45 2 46 2 47 2 48 2 49 2 50 2 51 2 52 2 53 2 54 2 55 2 56 2 57 2 58 2 59 2 60 2 61 2 62 2 63 2 64 2 65 2 66 2 67 2 68 2 69 2 70 2 71 2 72 2 73 2 74 2 75 2 76 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19 3 20 3 21 3 22 3 23 3 24 3 25 3 26 3 27 3 28 3 29 3 30 3 31 3 32 3 33 3 34 3 35 3 36 3 37 3 38 3 39 3 40 3 41 3 42 3 43 3 44 3 45 3 46 3 47 3 48 3 49 3 50 3 51 3 52 3 53 3 54 3 55 3 56 3 57 3 58 3 59 3 60 3 61 3 62 3 63 3 64 3 65 3 66 3 67 3 68 3 69 3 70 3 71 3 72 3 73 3 74 3 75 3 76 4 5 4 6 4 7 4 8 4 9 4 10 4 11 4 12 4 13 4 14 4 15 4 16 4 17 4 18 4 19 4 20 4 21 4 22 4 23 4 24 4 25 4 26 4 27 4 28 4 29 4 30 4 31 4 32 4 33 4 34 4 35 4 36 4 37 4 38 4 39 4 40 4 41 4 42 4 43 4 44 4 45 4 46 4 47 4 48 4 49 4 50 4 51 4 52 4 53 4 54 4 55 4 56 4 57 4 58 4 59 4 60 4 61 4 62 4 63 4 64 4 65 4 66 4 67 4 68 4 69 4 70 4 71 4 72 4 73 4 74 4 75 4 76 5 6 5 7 5 8 5 9 5 10 5 11 5 12 5 13 5 14 5 15 5 16 5 17 5 18 5 19 5 20 5 21 5 22 5 23 5 24 5 25 5 26 5 27 5 28 5 29 5 30 5 31 5 32 5 33 5 34 5 35 5 36 5 37 5 38 5 39 5 40 5 41 5 42 5 43 5\n", "1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 25 2 26 2 27 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19 3 20 3 21 3 22 3 23 3 24 3 25 3 26 3 27 4 5 4 6 4 7 4 8 4 9 4 10 4 11 4 12 4 13 4 14 4 15 4 16 4 17 4 18 4 19 4 20 4 21 4 22 4 23 4 24 4 25 4 26 4 27 5 6 5 7 5 8 5 9 5 10 5 11 5 12 5 13 5 14 5 15 5 16 5 17 5 18 5 19 5 20 5 21 5 22 5 23 5 24 5 25 5 26 5 27 6 7 6 8 6 9 6 10 6 11 6 12 6 13 6 14 6 15 6 16 6 17 6 18 6 19 6 20 6 21 6 22 6 23 6 24 6 25 6 26 6 27 7 8 7 9 7 10 7 11 7 12 7 13 7 14 7 15 7 16 7 17 7 18 7 19 7 20 7 21 7 22 7 23 7 24 7 25 7 26 7 27 8 9 8 10 8 11 8 12 8 13 8 14 8 15 8 16 8 17 8 18 8 19 8 20 8 21 8 22 8 23 8 24 8 25 8 26 8 27 9 10 9 11 9 12 9 13 9 14 9 15 9 16 9 17 9 18 9 19 9 20 9 21 9 22 9 23 9 24 9 25 9 26 9 27 10 11 10 12 10 13 10 14 10 15 10 16 10 17 10 18 10 19 10 20 10 21 10 22 10 23 10 24 10 25 10 26 10 27 11 12 11 13 11 14 11 15 11 16 11 17 11 18 11 19 11 20 11 21 11 22 11 23 11 24 11 25 11 26 11 27 12 13 12 14 12 15 12 16 12 17 12 18 12 19 12\n", "2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60 1 61 1 62 1 63 1 64 1 65 1 66 1 67 1 68 1 69 1 70 1 71 1 72 1 73 1 74 1 75 1 76 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 25 2 26 2 27 2 28 2 29 2 30 2 31 2 32 2 33 2 34 2 35 2 36 2 37 2 38 2 39 2 40 2 41 2 42 2 43 2 44 2 45 2 46 2 47 2 48 2 49 2 50 2 51 2 52 2 53 2 54 2 55 2 56 2 57 2 58 2 59 2 60 2 61 2 62 2 63 2 64 2 65 2 66 2 67 2 68 2 69 2 70 2 71 2 72 2 73 2 74 2 75 2 76 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19 3 20 3 21 3 22 3 23 3 24 3 25 3 26 3 27 3 28 3 29 3 30 3 31 3 32 3 33 3 34 3 35 3 36 3 37 3 38 3 39 3 40 3 41 3 42 3 43 3 44 3 45 3 46 3 47 3 48 3 49 3 50 3 51 3 52 3 53 3 54 3 55 3 56 3 57 3 58 3 59 3 60 3 61 3 62 3 63 3 64 3 65 3 66 3 67 3 68 3 69 3 70 3 71 3 72 3 73 3 74 3 75 3 76 4 5 4 6 4 7 4 8 4 9 4 10 4 11 4 12 4 13 4 14 4 15 4 16 4 17 4 18 4 19 4 20 4 21 4 22 4 23 4 24 4 25 4 26 4 27 4 28 4 29 4 30 4 31 4 32 4 33 4 34 4 35 4 36 4 37 4 38 4 39 4 40 4 41 4 42 4 43 4 44 4 45 4 46 4 47 4 48 4 49 4 50 4 51 4 52 4 53 4 54 4 55 4 56 4 57 4 58 4 59 4 60 4 61 4 62 4 63 4 64 4 65 4 66 4 67 4 68 4 69 4 70 4 71 4 72 4 73 4 74 4 75 4 76 5 6 5 7 5 8 5 9 5 10 5 11 5 12 5 13 5 14 5 15 5 16 5 17 5 18 5 19 5 20 5 21 5 22 5 23 5 24 5 25 5 26 5 27 5 28 5 29 5 30 5 31 5 32 5 33 5 34 5 35 5 36 5 37 5 38 5 39 5 40 5 41 5 42 5 43 5\n", "1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22\n", "3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60 1 61 1 62 1 63 1 64 1 65 1 66 1 67 1 68 1 69 1 70 1 71 1 72 1 73 1 74 1 75 1 76 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 25 2 26 2 27 2 28 2 29 2 30 2 31 2 32 2 33 2 34 2 35 2 36 2 37 2 38 2 39 2 40 2 41 2 42 2 43 2 44 2 45 2 46 2 47 2 48 2 49 2 50 2 51 2 52 2 53 2 54 2 55 2 56 2 57 2 58 2 59 2 60 2 61 2 62 2 63 2 64 2 65 2 66 2 67 2 68 2 69 2 70 2 71 2 72 2 73 2 74 2 75 2 76 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19 3 20 3 21 3 22 3 23 3 24 3 25 3 26 3 27 3 28 3 29 3 30 3 31 3 32 3 33 3 34 3 35 3 36 3 37 3 38 3 39 3 40 3 41 3 42 3 43 3 44 3 45 3 46 3 47 3 48 3 49 3 50 3 51 3 52 3 53 3 54 3 55 3 56 3 57 3 58 3 59 3 60 3 61 3 62 3 63 3 64 3 65 3 66 3 67 3 68 3 69 3 70 3 71 3 72 3 73 3 74 3 75 3 76 4 5 4 6 4 7 4 8 4 9 4 10 4 11 4 12 4 13 4 14 4 15 4 16 4 17 4 18 4 19 4 20 4 21 4 22 4 23 4 24 4 25 4 26 4 27 4 28 4 29 4 30 4 31 4 32 4 33 4 34 4 35 4 36 4 37 4 38 4 39 4 40 4 41 4 42 4 43 4 44 4 45 4 46 4 47 4 48 4 49 4 50 4 51 4 52 4 53 4 54 4 55 4 56 4 57 4 58 4 59 4 60 4 61 4 62 4 63 4 64 4 65 4 66 4 67 4 68 4 69 4 70 4 71 4 72 4 73 4 74 4 75 4 76 5 6 5 7 5 8 5 9 5 10 5 11 5 12 5 13 5 14 5 15 5 16 5 17 5 18 5 19 5 20 5 21 5 22 5 23 5 24 5 25 5 26 5 27 5 28 5 29 5 30 5 31 5 32 5 33 5 34 5 35 5 36 5 37 5 38 5 39 5 40 5 41 5 42 5 43 5\n", "5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60 1 61 1 62 1 63 1 64 1 65 1 66 1 67 1 68 1 69 1 70 1 71 1 72 1 73 1 74 1 75 1 76 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 25 2 26 2 27 2 28 2 29 2 30 2 31 2 32 2 33 2 34 2 35 2 36 2 37 2 38 2 39 2 40 2 41 2 42 2 43 2 44 2 45 2 46 2 47 2 48 2 49 2 50 2 51 2 52 2 53 2 54 2 55 2 56 2 57 2 58 2 59 2 60 2 61 2 62 2 63 2 64 2 65 2 66 2 67 2 68 2 69 2 70 2 71 2 72 2 73 2 74 2 75 2 76 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19 3 20 3 21 3 22 3 23 3 24 3 25 3 26 3 27 3 28 3 29 3 30 3 31 3 32 3 33 3 34 3 35 3 36 3 37 3 38 3 39 3 40 3 41 3 42 3 43 3 44 3 45 3 46 3 47 3 48 3 49 3 50 3 51 3 52 3 53 3 54 3 55 3 56 3 57 3 58 3 59 3 60 3 61 3 62 3 63 3 64 3 65 3 66 3 67 3 68 3 69 3 70 3 71 3 72 3 73 3 74 3 75 3 76 4 5 4 6 4 7 4 8 4 9 4 10 4 11 4 12 4 13 4 14 4 15 4 16 4 17 4 18 4 19 4 20 4 21 4 22 4 23 4 24 4 25 4 26 4 27 4 28 4 29 4 30 4 31 4 32 4 33 4 34 4 35 4 36 4 37 4 38 4 39 4 40 4 41 4 42 4 43 4 44 4 45 4 46 4 47 4 48 4 49 4 50 4 51 4 52 4 53 4 54 4 55 4 56 4 57 4 58 4 59 4 60 4 61 4 62 4 63 4 64 4 65 4 66 4 67 4 68 4 69 4 70 4 71 4 72 4 73 4 74 4 75 4 76 5 6 5 7 5 8 5 9 5 10 5 11 5 12 5 13 5 14 5 15 5 16 5 17 5 18 5 19 5 20 5 21 5 22 5 23 5 24 5 25 5 26 5 27 5 28 5 29 5 30 5 31 5 32 5 33 5 34 5 35 5 36 5 37 5 38 5 39 5 40 5 41 5 42 5 43 5\n", "5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60 1 61 1 62 1 63 1 64 1 65 1 66 1 67 1 68 1 69 1 70 1 71 1 72 1 73 1 74 1 75 1 76 1 77 1 78 1 79 1 80 1 81 1 82 1 83 1 84 1 85 1 86 1 87 1 88 1 89 1 90 1 91 1 92 1 93 1 94 1 95 1 96 1 97 1 98 1 99 1 100 1 101 1 102 1 103 1 104 1 105 1 106 1 107 1 108 1 109 1 110 1 111 1 112 1 113 1 114 1 115 1 116 1 117 1 118 1 119 1 120 1 121 1 122 1 123 1 124 1 125 1 126 1 127 1 128 1 129 1 130 1 131 1 132 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 25 2 26 2 27 2 28 2 29 2 30 2 31 2 32 2 33 2 34 2 35 2 36 2 37 2 38 2 39 2 40 2 41 2 42 2 43 2 44 2 45 2 46 2 47 2 48 2 49 2 50 2 51 2 52 2 53 2 54 2 55 2 56 2 57 2 58 2 59 2 60 2 61 2 62 2 63 2 64 2 65 2 66 2 67 2 68 2 69 2 70 2 71 2 72 2 73 2 74 2 75 2 76 2 77 2 78 2 79 2 80 2 81 2 82 2 83 2 84 2 85 2 86 2 87 2 88 2 89 2 90 2 91 2 92 2 93 2 94 2 95 2 96 2 97 2 98 2 99 2 100 2 101 2 102 2 103 2 104 2 105 2 106 2 107 2 108 2 109 2 110 2 111 2 112 2 113 2 114 2 115 2 116 2 117 2 118 2 119 2 120 2 121 2 122 2 123 2 124 2 125 2 126 2 127 2 128 2 129 2 130 2 131 2 132 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19 3 20 3 21 3 22 3 23 3 24 3 25 3 26 3 27 3 28 3 29 3 30 3 31 3 32 3 33 3 34 3 35 3 36 3 37 3 38 3 39 3 40 3 41 3 42 3 43 3 44 3 45 3 46 3 47 3 48 3 49 3 50 3 51 3 52 3 53 3 54 3 55 3 56 3 57 3 58 3 59 3 60 3 61 3 62 3 63 3 64 3 65 3 66 3 67 3 68 3 69 3 70 3 71 3 72 3 73 3 74 3\n", "1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60 1 61 1 62 1 63 1 64 1 65 1 66 1 67 1 68 1 69 1 70 1 71 1 72 1 73 1 74 1 75 1 76 1 77 1 78 1 79 1 80 1 81 1 82 1 83 1 84 1 85 1 86 1 87 1 88 1 89 1 90 1 91 1 92 1 93 1 94 1 95 1 96 1 97 1 98 1 99 1 100 1 101 1 102 1 103 1 104 1 105 1 106 1 107 1 108 1 109 1 110 1 111 1 112 1 113 1 114 1 115 1 116 1 117 1 118 1 119 1 120 1 121 1 122 1 123 1 124 1 125 1 126 1 127 1 128 1 129 1 130 1 131 1 132 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 25 2 26 2 27 2 28 2 29 2 30 2 31 2 32 2 33 2 34 2 35 2 36 2 37 2 38 2 39 2 40 2 41 2 42 2 43 2 44 2 45 2 46 2 47 2 48 2 49 2 50 2 51 2 52 2 53 2 54 2 55 2 56 2 57 2 58 2 59 2 60 2 61 2 62 2 63 2 64 2 65 2 66 2 67 2 68 2 69 2 70 2 71 2 72 2 73 2 74 2 75 2 76 2 77 2 78 2 79 2 80 2 81 2 82 2 83 2 84 2 85 2 86 2 87 2 88 2 89 2 90 2 91 2 92 2 93 2 94 2 95 2 96 2 97 2 98 2 99 2 100 2 101 2 102 2 103 2 104 2 105 2 106 2 107 2 108 2 109 2 110 2 111 2 112 2 113 2 114 2 115 2 116 2 117 2 118 2 119 2 120 2 121 2 122 2 123 2 124 2 125 2 126 2 127 2 128 2 129 2 130 2 131 2 132 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19 3 20 3 21 3 22 3 23 3 24 3 25 3 26 3 27 3 28 3 29 3 30 3 31 3 32 3 33 3 34 3 35 3 36 3 37 3 38 3 39 3 40 3 41 3 42 3 43 3 44 3 45 3 46 3 47 3 48 3 49 3 50 3 51 3 52 3 53 3 54 3 55 3 56 3 57 3 58 3 59 3 60 3 61 3 62 3 63 3 64 3 65 3 66 3 67 3 68 3 69 3 70 3 71 3 72 3 73 3 74 3\n", "1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1\n", "1 12 1 13 1 14 1 15 1 16 1 17 1\n", "1 2 1\n1 2 1\n1 2 1\n1 2 1\n1 2 1\n1 2 1\n1 2 1\n1 2 1\n2 1\n1 2 1\n", "22 1 23 1 24 1 25 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 25 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19 3 20 3 21 3 22 3 23 3 24 3 25 4 5 4 6 4 7 4 8 4 9 4 10 4 11 4 12 4 13 4 14 4 15 4 16 4 17 4 18 4 19 4 20 4 21 4 22 4 23 4 24 4 25 5 6 5 7 5 8 5 9 5 10 5 11 5 12 5 13 5 14 5 15 5 16 5 17 5 18 5 19 5 20 5 21 5 22 5 23 5 24 5 25 6 7 6 8 6 9 6 10 6 11 6 12 6 13 6 14 6 15 6 16 6 17 6 18 6 19 6 20 6 21 6 22 6 23 6 24 6 25 7 8 7 9 7 10 7 11 7 12 7 13 7 14 7 15 7 16 7 17 7 18 7 19 7 20 7 21 7 22 7 23 7 24 7 25 8\n", "1 2 1 3 1 4 1 5 2 3 2 4 2\n", "1 2 1\n3 2 3 1\n1\n", "25 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 25 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19 3 20 3 21 3 22 3 23 3 24 3 25 4 5 4 6 4 7 4 8 4 9 4 10 4 11 4 12 4 13 4 14 4 15 4 16 4 17 4 18 4 19 4 20 4 21 4 22 4 23 4 24 4 25 5 6 5 7 5 8 5 9 5 10 5 11 5 12 5 13 5 14 5 15 5 16 5 17 5 18 5 19 5 20 5 21 5 22 5 23 5 24 5 25 6 7 6 8 6 9 6 10 6 11 6 12 6 13 6 14 6 15 6 16 6 17 6 18 6 19 6 20 6 21 6 22 6 23 6 24 6 25 7 8 7 9 7 10 7 11 7 12 7 13 7 14 7 15 7 16 7 17 7 18 7 19 7 20 7 21 7 22 7 23 7 24 7 25 8 9 8 10 8 11 8 12 8 13 8 14 8 15 8 16 8 17 8 18 8 19 8 20 8 21 8 22 8 23 8 24 8 25 9 10 9 11 9 12 9 13 9 14 9 15 9 16 9 17 9 18 9 19 9 20 9 21 9 22 9 23 9 24 9 25 10 11 10 12 10 13 10 14 10 15 10 16 10 17 10 18 10 19 10 20 10 21 10 22 10 23 10 24 10 25 11 12 11 13 11 14 11 15 11 16 11 17 11 18 11 19 11 20 11 21 11 22 11 23 11 24 11 25 12 13 12 14 12 15 12 16 12 17 12\n", "2 1 3 1 4 1\n", "1 2 1 3 1 4 2 3 2\n", "1 2 1 3 1 4 1 5 1 6 1 7 1 8\n", "16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 25 2 26 2 27 2 28 2 29 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19 3 20 3 21 3 22 3 23 3 24 3 25 3 26 3 27 3 28 3 29 4 5 4 6 4 7 4 8 4 9 4 10 4 11 4 12 4 13 4 14 4 15 4 16 4 17 4 18 4 19 4 20 4 21 4 22 4 23 4 24 4 25 4 26 4 27 4 28 4 29 5 6 5 7 5 8 5 9 5 10 5 11 5 12 5 13 5 14 5 15 5 16 5 17 5 18 5 19 5 20 5 21 5 22 5 23 5 24 5 25 5 26 5 27 5 28 5 29 6 7 6 8 6 9 6 10 6 11 6 12 6 13 6 14 6 15 6 16 6 17 6 18 6 19 6 20 6 21 6 22 6 23 6 24 6 25 6 26 6 27 6 28 6 29 7 8 7 9 7 10 7 11 7 12 7 13 7 14 7 15 7 16 7 17 7 18 7 19 7 20 7 21 7 22 7 23 7 24 7 25 7 26 7 27 7 28 7 29 8 9 8 10 8 11 8 12 8 13 8 14 8 15 8 16 8 17 8 18 8 19 8 20 8 21 8 22 8 23 8 24 8 25 8 26 8 27 8 28 8 29 9 10 9 11 9 12 9 13 9 14 9 15 9 16 9 17 9 18 9 19 9 20 9 21 9 22 9 23 9 24 9 25 9 26 9 27 9 28 9 29 10 11 10 12 10 13 10 14 10 15 10 16\n", "1\n1\n2 4 2 5 2 6 3 4 3\n1\n7 1\n", "16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 25 2 26 2 27 2 28 2 29 2 30 2 31 2 32 2 33 2 34 2 35 2 36 2 37 2 38 2 39 2 40 2 41 2 42 2 43 2 44 2 45 2 46 2 47 2 48 2 49 2 50 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19 3 20 3 21 3 22 3 23 3 24 3 25 3 26 3 27 3 28 3 29 3 30 3 31 3 32 3 33 3 34 3 35 3 36 3 37 3 38 3 39 3 40 3 41 3 42 3 43 3 44 3 45 3 46 3 47 3 48 3 49 3 50 4 5 4 6 4 7 4 8 4 9 4 10 4 11 4 12 4 13 4 14 4 15 4 16 4 17 4 18 4 19 4 20 4 21 4 22 4 23 4 24 4 25 4 26 4 27 4 28 4 29 4 30 4 31 4 32 4 33 4 34 4 35 4 36 4 37 4 38 4 39 4 40 4 41 4 42 4 43 4 44 4 45 4 46 4 47 4 48 4 49 4 50 5 6 5 7 5 8 5 9 5 10 5 11 5 12 5 13 5 14 5 15 5 16 5 17 5 18 5 19 5 20 5 21 5 22 5 23 5 24 5 25 5 26 5 27 5 28 5 29 5 30 5 31 5 32 5 33 5 34 5 35 5 36 5 37 5 38 5 39 5 40 5 41 5 42 5 43 5 44 5 45 5 46 5 47 5 48 5 49 5 50 6 7 6 8 6 9 6 10 6 11 6 12 6 13 6 14 6 15 6 16 6 17 6 18 6 19 6 20 6 21\n", "1 2 1\n2 1 3 2 3\n1\n", "4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 25 2 26 2 27 2 28 2 29 2 30 2 31 2 32 2 33 2 34 2 35 2 36 2 37 2 38 2 39 2 40 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19 3 20 3 21 3 22 3 23 3 24 3 25 3 26 3 27 3 28 3 29 3 30 3 31 3 32 3 33 3 34 3 35 3 36 3 37 3 38 3 39 3 40 4 5 4 6 4 7 4 8 4 9 4 10 4 11 4 12 4 13 4 14 4 15 4 16 4 17 4 18 4 19 4 20 4 21 4 22 4 23 4 24 4 25 4 26 4 27 4 28 4 29 4 30 4 31 4 32 4 33 4 34 4 35 4 36 4 37 4\n", "1\n1\n2 5 3 4 3 5 4 5 1\n1\n8 3 4 3 5 3 6 3 7 3 8 4 5 4 6 4 7 4\n", "16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 25 2 26 2 27 2 28 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19 3 20 3 21 3 22 3 23 3 24 3 25 3 26 3 27 3 28 4 5 4 6 4 7 4 8 4 9 4 10 4 11 4 12 4 13 4 14 4 15 4 16 4 17 4 18 4 19 4 20 4 21 4 22 4 23 4 24 4 25 4 26 4 27 4 28 5 6 5 7 5 8 5 9 5 10 5 11 5 12 5 13 5 14 5 15 5 16 5 17 5 18 5 19 5 20 5 21 5 22 5 23 5 24 5 25 5 26 5 27 5 28 6 7 6 8 6 9 6 10 6 11 6 12 6 13 6 14 6 15 6 16 6 17 6 18 6 19 6 20 6 21 6 22 6 23 6 24 6 25 6 26 6 27 6 28 7 8 7 9 7 10 7 11 7 12 7 13 7 14 7 15 7 16 7 17 7 18 7 19 7 20 7 21 7 22 7 23 7 24 7 25 7 26 7 27 7 28 8 9 8 10 8 11 8 12 8 13 8 14 8 15 8 16 8 17 8 18 8 19 8 20 8 21 8 22 8 23\n", "31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 25 2 26 2 27 2 28 2 29 2 30 2 31 2 32 2 33 2 34 2 35 2 36 2 37 2 38 2 39 2 40 2 41 2 42 2 43 2 44 2 45 2 46 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19 3 20 3 21 3 22 3 23 3 24 3 25 3 26 3 27 3 28 3 29 3 30 3 31 3 32 3 33 3 34 3 35 3 36 3 37 3 38 3 39 3 40 3 41 3 42 3 43 3 44 3 45 3 46 4 5 4 6 4 7 4 8 4 9 4 10 4 11 4 12 4 13 4 14 4 15 4 16 4 17 4 18 4 19 4 20 4 21 4 22 4 23 4 24 4 25 4 26 4 27 4 28 4 29 4 30 4 31 4 32 4 33 4 34 4 35 4 36 4 37 4 38 4 39 4 40 4 41 4 42 4 43 4 44 4 45 4 46 5 6 5 7 5 8 5 9 5 10 5 11 5 12 5 13 5 14 5 15 5 16 5 17 5 18 5 19 5 20 5 21 5 22 5 23 5 24 5 25 5 26 5 27 5 28 5 29 5 30 5 31 5 32 5 33 5 34 5 35 5 36 5 37 5 38 5 39 5 40 5 41 5 42 5 43 5 44 5 45 5\n", "2 1 3 1 4 1 5 2 3 2 4 2 5\n", "1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60 1 61 1 62 1 63 1 64 1 65 1 66 1 67 1 68 1 69 1 70 1 71 1 72 1 73 1 74 1 75 1 76 1 77 1 78 1 79 1 80 1 81 1 82 1 83 1 84 1 85 1 86 1 87 1 88 1 89 1 90 1 91 1 92 1 93 1 94 1 95 1 96 1 97 1 98 1 99 1 100 1 101 1 102 1 103 1 104 1 105 1 106 1 107 1 108 1 109 1 110 1 111 1 112 1 113 1 114 1 115 1 116 1 117 1 118 1 119 1 120 1 121 1 122 1 123 1 124 1 125 1 126 1 127 1 128 1 129 1 130 1 131 1 132 1 133 1 134 1 135 1 136 1 137 1 138 1 139 1 140 1 141 1 142 1 143 1 144 1 145 1 146 1 147 1 148 1 149 1 150 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 25 2 26 2 27 2 28 2 29 2 30 2 31 2 32 2 33 2 34 2 35 2 36 2 37 2 38 2 39 2 40 2 41 2 42 2 43 2 44 2 45 2 46 2 47 2 48 2 49 2 50 2 51 2 52 2 53 2 54 2 55 2 56 2 57 2 58 2 59 2 60 2 61 2 62 2 63 2 64 2 65 2 66 2 67 2\n", "5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 25 2 26 2 27 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19\n", "1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 25 2 26 2 27 2 28 2 29 2 30 2 31 2 32 2 33 2 34 2 35 2 36 2 37 2 38 2 39 2 40 2 41 2 42 2 43 2 44 2 45 2 46 2 47 2 48 2 49 2 50 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19 3 20 3 21 3 22 3 23 3 24 3 25 3 26 3 27 3 28 3 29 3 30 3 31 3 32 3 33 3 34 3 35 3 36 3 37 3 38 3 39 3 40 3 41 3 42 3 43 3 44 3 45 3 46 3 47 3 48 3 49 3 50 4 5 4 6 4 7 4 8 4 9 4 10 4 11 4 12 4 13 4 14 4 15 4 16 4 17 4 18 4 19 4 20 4 21 4 22 4 23 4 24 4 25 4 26 4 27 4 28 4 29 4 30 4 31 4 32 4 33 4 34 4 35 4 36 4 37 4 38 4 39 4 40 4 41 4 42 4 43 4 44 4 45 4 46 4 47 4 48 4 49 4 50 5 6 5 7 5 8 5 9 5 10 5 11 5 12 5 13 5 14 5 15 5 16 5 17 5 18 5 19 5 20 5 21 5 22 5 23 5 24 5 25 5 26 5 27 5 28 5 29 5 30 5 31 5 32 5 33 5 34 5 35 5 36 5 37 5 38 5 39 5 40 5 41 5 42 5 43 5 44 5 45 5 46 5 47 5 48 5 49 5 50 6 7 6 8 6 9 6 10 6 11 6 12 6 13 6 14 6 15 6 16 6 17 6 18 6 19 6 20 6 21 6 22 6 23 6 24 6 25 6 26 6 27 6 28 6 29 6 30 6 31 6 32 6 33 6 34 6 35 6 36 6 37 6 38 6 39 6 40 6 41 6 42 6 43 6 44 6 45 6 46 6 47 6 48 6 49 6 50 7 8 7 9 7 10 7 11 7 12 7 13 7 14 7 15\n", "1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 25 2 26 2 27 2 28 2 29 2 30 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19 3 20 3 21 3 22 3 23 3 24 3 25 3 26 3 27 3 28 3 29 3 30 4 5 4 6 4 7 4 8 4 9 4 10 4 11 4 12 4 13 4 14 4 15 4 16 4 17 4 18 4 19 4 20 4 21 4 22 4 23 4 24 4 25 4 26 4 27 4 28 4 29 4 30 5 6 5 7 5 8 5 9 5 10 5 11 5 12 5 13 5 14 5 15 5 16 5 17 5 18 5 19 5 20 5 21 5 22 5 23 5 24 5 25 5 26 5 27 5 28 5 29 5 30 6 7 6 8 6 9 6 10 6 11 6 12 6 13 6 14 6 15 6 16 6 17 6 18 6\n", "19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60 1 61 1 62 1 63 1 64 1 65 1 66 1 67 1 68 1 69 1 70 1 71 1 72 1 73 1 74 1 75 1 76 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 25 2 26 2 27 2 28 2 29 2 30 2 31 2 32 2 33 2 34 2 35 2 36 2 37 2 38 2 39 2 40 2 41 2 42 2 43 2 44 2 45 2 46 2 47 2 48 2 49 2 50 2 51 2 52 2 53 2 54 2 55 2 56 2 57 2 58 2 59 2 60 2 61 2 62 2 63 2 64 2 65 2 66 2 67 2 68 2 69 2 70 2 71 2 72 2 73 2 74 2 75 2 76 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19 3 20 3 21 3 22 3 23 3 24 3 25 3 26 3 27 3 28 3 29 3 30 3 31 3 32 3 33 3 34 3 35 3 36 3 37 3 38 3 39 3 40 3 41 3 42 3 43 3 44 3 45 3 46 3 47 3 48 3 49 3 50 3 51 3 52 3 53 3 54 3 55 3 56 3 57 3 58 3 59 3 60 3 61 3 62 3 63 3 64 3 65 3 66 3 67 3 68 3 69 3 70 3 71 3 72 3 73 3 74 3 75 3 76 4 5 4 6 4 7 4 8 4 9 4 10 4 11 4 12 4 13 4 14 4 15 4 16 4 17 4 18 4 19 4 20 4 21 4 22 4 23 4 24 4 25 4 26 4 27 4 28 4 29 4 30 4 31 4 32 4 33 4 34 4 35 4 36 4 37 4 38 4 39 4 40 4 41 4 42 4 43 4 44 4 45 4 46 4 47 4 48 4 49 4 50 4 51 4 52 4 53 4 54 4 55 4 56 4 57 4 58 4 59 4 60 4 61 4 62 4 63 4 64 4 65 4 66 4 67 4 68 4 69 4 70 4 71 4 72 4 73 4 74 4 75 4 76 5 6 5 7 5 8 5 9 5 10 5 11 5 12 5 13 5 14 5 15 5 16 5 17 5 18 5 19 5 20 5 21 5 22 5 23 5 24 5 25 5 26 5 27 5 28 5 29 5 30 5 31 5 32 5 33 5 34 5 35 5 36 5 37 5 38 5 39 5 40 5 41 5 42 5 43 5\n", "1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 25 2 26 2 27 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19 3 20 3 21 3 22 3 23 3 24 3 25 3 26 3 27 4 5 4 6 4 7 4 8 4 9 4 10 4 11 4 12 4 13 4 14 4 15 4 16 4 17 4 18 4 19 4 20 4 21 4 22 4 23 4 24 4 25 4 26 4 27 5 6 5 7 5 8 5 9 5 10 5 11 5 12 5 13 5 14 5 15 5 16 5 17 5 18 5 19 5 20 5 21 5 22 5 23 5 24 5 25 5 26 5 27 6 7 6 8 6 9 6 10 6 11 6 12 6 13 6 14 6 15 6 16 6 17 6 18 6 19 6 20 6 21 6 22 6 23 6 24 6 25 6 26 6 27 7 8 7 9 7 10 7 11 7 12 7 13 7 14 7 15 7 16 7 17 7 18 7 19 7 20 7 21 7 22 7 23 7 24 7 25 7 26 7 27 8 9 8 10 8 11 8 12 8 13 8 14 8 15 8 16 8 17 8 18 8 19 8 20 8 21 8 22 8 23 8 24 8 25 8 26 8 27 9 10 9 11 9 12 9 13 9 14 9 15 9 16 9 17 9 18 9 19 9 20 9 21 9 22 9 23 9 24 9 25 9 26 9 27 10 11 10 12 10 13 10 14 10 15 10 16 10 17 10 18 10 19 10 20 10 21 10 22 10 23 10 24 10 25 10 26 10 27 11 12 11 13 11 14 11 15 11 16 11 17 11 18 11 19 11 20 11 21 11 22 11 23 11 24 11 25 11 26 11 27 12 13 12 14 12 15 12 16 12 17 12 18 12 19 12 20 12 21 12 22 12 23 12 24 12 25 12 26 12 27 13 14 13 15 13 16 13 17 13 18 13 19 13 20 13 21 13 22 13 23 13 24 13 25 13 26 13 27 14 15 14 16 14 17 14 18 14 19 14 20 14 21 14 22 14 23 14 24 14 25 14 26 14 27 15 16 15 17 15 18 15 19 15 20 15 21 15 22 15 23 15 24 15 25 15 26 15 27 16 17 16 18 16 19 16 20 16 21 16 22 16 23 16 24 16 25 16 26 16 27 17 18 17 19 17\n", "24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57\n", "2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 25 2 26 2 27 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19 3 20 3 21 3 22 3 23 3 24 3 25 3 26 3 27 4 5 4 6 4 7 4 8 4 9 4 10 4 11 4 12 4 13 4 14 4 15 4 16 4 17 4 18 4 19 4 20 4 21 4 22 4 23 4 24 4 25 4 26 4 27 5 6 5 7 5 8 5 9 5 10 5 11 5 12 5 13 5 14 5 15 5 16 5 17 5 18 5 19 5 20 5 21 5 22 5 23 5 24 5 25 5 26 5 27 6 7 6 8 6 9 6 10 6 11 6 12 6 13 6 14 6 15 6 16 6 17 6 18 6 19 6 20 6 21 6 22 6 23 6 24 6 25 6 26 6 27 7 8 7 9 7 10 7 11 7 12 7 13 7 14 7 15 7 16 7 17 7 18 7 19 7 20 7 21 7 22 7 23 7 24 7 25 7 26 7 27 8 9 8 10 8 11 8 12 8 13 8 14 8 15 8 16 8 17 8 18 8 19 8 20 8 21 8 22 8 23 8 24 8 25 8 26 8 27 9 10 9 11 9 12 9 13 9 14 9 15 9 16 9 17 9 18 9 19 9 20 9 21 9 22 9 23 9 24 9 25 9 26 9 27 10 11 10 12 10 13 10 14 10 15 10 16 10 17 10 18 10 19 10 20 10 21 10 22 10 23 10 24 10 25 10 26 10 27 11 12 11 13 11 14 11 15 11 16 11 17 11 18 11 19 11 20 11 21 11 22 11 23 11 24 11 25 11 26 11 27 12 13 12 14 12 15 12 16 12 17 12 18 12 19 12\n", "2 1 3 1\n", "1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 3 4 3 5 3 6 3 7 3 8 3 9 3 10\n", "3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60 1 61 1 62 1 63 1 64 1 65 1 66 1 67 1 68 1 69 1 70 1 71 1 72 1 73 1 74 1 75 1 76 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 25 2 26 2 27 2 28 2 29 2 30 2 31 2 32 2 33 2 34 2 35 2 36 2 37 2 38 2 39 2 40 2 41 2 42 2 43 2 44 2 45 2 46 2 47 2 48 2 49 2 50 2 51 2 52 2 53 2 54 2 55 2 56 2 57 2 58 2 59 2 60 2 61 2 62 2 63 2 64 2 65 2 66 2 67 2 68 2 69 2 70 2 71 2 72 2 73 2 74 2 75 2 76 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19 3 20 3 21 3 22 3 23 3 24 3 25 3 26 3 27 3 28 3 29 3 30 3 31 3 32 3 33 3 34 3 35 3 36 3 37 3 38 3 39 3 40 3 41 3 42 3 43 3 44 3 45 3 46 3 47 3 48 3 49 3 50 3 51 3 52 3 53 3 54 3 55 3 56 3 57 3 58 3 59 3 60 3 61 3 62 3 63 3 64 3 65 3 66 3 67 3 68 3 69 3 70 3 71 3 72 3 73 3 74 3 75 3 76 4 5 4 6 4 7 4 8 4 9 4 10 4 11 4 12 4 13 4 14 4 15 4 16 4 17 4 18 4 19 4 20 4 21 4 22 4 23 4 24 4 25 4 26 4 27 4 28 4 29 4 30 4 31 4 32 4 33 4 34 4 35 4 36 4 37 4 38 4 39 4 40 4 41 4 42 4 43 4 44 4 45 4 46 4 47 4 48 4 49 4 50 4 51 4 52 4 53 4 54 4 55 4 56 4 57 4 58 4 59 4 60 4 61 4 62 4 63 4 64 4 65 4 66 4 67 4 68 4 69 4 70 4 71 4 72 4 73 4 74 4 75 4 76 5 6 5 7 5 8 5 9 5 10 5 11 5 12 5 13 5 14 5 15 5 16 5 17 5 18 5 19 5 20 5 21 5 22 5 23 5 24 5 25 5 26 5 27 5 28 5 29 5 30 5 31 5 32 5 33 5 34 5 35 5 36 5 37 5 38 5 39 5 40 5 41 5 42 5 43 5 44 5 45 5 46 5 47 5 48 5 49 5 50 5 51 5 52 5 53 5 54 5 55 5 56 5 57 5 58 5 59 5 60 5 61 5 62 5 63 5 64 5 65 5 66 5 67 5 68 5 69 5 70 5 71 5 72 5 73 5 74 5 75 5 76 6 7 6 8 6 9 6 10 6 11 6 12 6 13 6 14 6 15 6 16 6 17 6 18 6 19 6 20 6 21 6 22 6 23 6 24 6 25 6 26 6 27 6 28 6 29 6 30 6 31 6 32 6 33 6 34 6 35 6 36 6 37 6 38 6 39 6 40 6 41 6 42 6 43 6 44 6 45 6 46 6 47 6 48 6 49 6 50 6 51 6 52 6 53 6 54 6 55 6 56 6 57 6 58 6 59 6 60 6 61 6 62 6 63 6 64 6 65 6 66 6 67 6 68 6 69 6 70 6 71 6 72 6 73 6 74 6 75 6 76 7 8 7 9 7 10 7 11 7 12 7 13 7 14 7 15 7 16 7 17 7 18 7 19 7 20 7 21 7 22 7 23 7 24 7 25 7 26 7 27 7 28 7 29 7 30 7 31 7 32 7 33 7 34 7 35 7 36 7 37 7 38 7 39 7 40 7 41 7 42 7 43 7 44 7 45 7 46 7 47 7 48 7 49 7 50 7 51 7 52 7 53 7 54 7 55 7 56 7 57 7 58 7 59 7 60 7 61 7 62 7 63 7 64 7 65 7 66 7 67 7 68 7 69 7 70 7 71 7 72 7 73 7 74 7 75 7 76 8 9 8 10 8 11 8 12 8 13 8 14 8 15 8 16 8 17 8 18 8 19 8 20 8 21 8 22 8 23 8 24 8 25 8 26 8 27 8 28 8 29 8 30 8 31 8 32 8 33 8 34 8 35 8 36 8 37 8 38 8 39 8 40 8 41 8 42 8 43 8 44 8 45 8 46 8 47 8 48 8 49 8 50 8 51 8 52 8 53 8 54 8 55 8 56 8 57 8 58 8 59 8 60 8 61 8 62 8 63 8 64 8 65 8 66 8 67 8 68 8 69 8 70 8 71 8 72 8 73 8 74 8 75 8 76 9 10 9 11 9 12 9 13 9 14 9 15 9 16 9 17 9 18 9 19 9 20 9 21 9 22 9 23 9 24 9 25 9 26 9 27 9 28 9 29 9 30 9 31 9 32 9 33 9 34 9 35 9 36 9 37 9 38 9 39 9 40 9 41 9 42 9 43 9 44 9 45 9 46 9 47 9 48 9 49 9 50 9 51 9 52 9 53 9 54 9 55 9 56 9 57 9 58 9 59 9 60 9 61 9 62 9 63 9 64 9 65 9 66 9 67 9 68 9\n", "5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60 1 61 1 62 1 63 1 64 1 65 1 66 1 67 1 68 1 69 1 70 1 71 1 72 1 73 1 74 1 75 1 76 1 77 1 78 1 79 1 80 1 81 1 82 1 83 1 84 1 85 1 86 1 87 1 88 1 89 1 90 1 91 1 92 1 93 1 94 1 95 1 96 1 97 1 98 1 99 1 100 1 101 1 102 1 103 1 104 1 105 1 106 1 107 1 108 1 109 1 110 1 111 1 112 1 113 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 25 2 26 2 27 2 28 2 29 2 30 2 31 2 32 2 33 2 34 2 35 2 36 2 37 2 38 2 39 2 40 2 41 2 42 2 43 2 44 2 45 2 46 2 47 2 48 2 49 2 50 2 51 2 52 2 53 2 54 2 55 2 56 2 57 2 58 2 59 2 60 2 61 2 62 2 63 2 64 2 65 2 66 2 67 2 68 2 69 2 70 2 71 2 72 2 73 2 74 2 75 2 76 2 77 2 78 2 79 2 80 2 81 2 82 2 83 2 84 2 85 2 86 2 87 2 88 2 89 2 90 2 91 2 92 2 93 2 94 2 95 2 96 2 97 2 98 2 99 2 100 2 101 2 102 2 103 2 104 2 105 2 106 2 107 2 108 2 109 2 110 2 111 2 112 2 113 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19 3 20 3 21 3 22 3 23 3 24 3 25 3 26 3 27 3 28 3 29 3 30 3 31 3 32 3 33 3 34 3 35 3 36 3 37 3 38 3 39 3 40 3 41 3 42 3 43 3 44 3 45 3 46 3 47 3 48 3 49 3 50 3 51 3 52 3 53 3 54 3 55 3 56 3 57 3 58 3 59 3 60 3 61 3 62 3 63 3 64 3 65 3 66 3 67 3 68 3 69 3 70 3 71 3 72 3 73 3 74 3 75 3 76 3 77 3 78 3 79 3 80 3 81 3 82 3 83 3 84 3 85 3 86 3 87 3 88 3 89 3 90 3 91 3 92 3 93 3 94 3 95 3 96 3 97 3 98 3 99 3 100 3 101 3 102 3 103 3 104 3 105 3 106 3 107 3 108 3 109 3 110 3 111 3 112 3\n", "5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60 1 61 1 62 1 63 1 64 1 65 1 66 1 67 1 68 1 69 1 70 1 71 1 72 1 73 1 74 1 75 1 76 1 77 1 78 1 79 1 80 1 81 1 82 1 83 1 84 1 85 1 86 1 87 1 88 1 89 1 90 1 91 1 92 1 93 1 94 1 95 1 96 1 97 1 98 1 99 1 100 1 101 1 102 1 103 1 104 1 105 1 106 1 107 1 108 1 109 1 110 1 111 1 112 1 113 1 114 1 115 1 116 1 117 1 118 1 119 1 120 1 121 1 122 1 123 1 124 1 125 1 126 1 127 1 128 1 129 1 130 1 131 1 132 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 25 2 26 2 27 2 28 2 29 2 30 2 31 2 32 2 33 2 34 2 35 2 36 2 37 2 38 2 39 2 40 2 41 2 42 2 43 2 44 2 45 2 46 2 47 2 48 2 49 2 50 2 51 2 52 2 53 2 54 2 55 2 56 2 57 2 58 2 59 2 60 2 61 2 62 2 63 2 64 2 65 2 66 2 67 2 68 2 69 2 70 2 71 2 72 2 73 2 74 2 75 2 76 2 77 2 78 2 79 2 80 2 81 2 82 2 83 2 84 2 85 2 86 2 87 2 88 2 89 2 90 2 91 2 92 2 93 2 94 2 95 2 96 2 97 2 98 2 99 2 100 2 101 2 102 2 103 2 104 2 105 2 106 2 107 2 108 2 109 2 110 2 111 2 112 2 113 2 114 2 115 2 116 2 117 2 118 2 119 2 120 2 121 2 122 2 123 2 124 2 125 2 126 2 127 2 128 2 129 2 130 2 131 2 132 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19 3 20 3 21 3 22 3 23 3 24 3 25 3 26 3 27 3 28 3 29 3 30 3 31 3 32 3 33 3 34 3 35 3 36 3 37 3 38 3 39 3 40 3 41 3 42 3 43 3 44 3 45 3 46 3 47 3 48 3 49 3 50 3 51 3 52 3 53 3 54 3 55 3 56 3 57 3 58 3 59 3 60 3 61 3 62 3 63 3 64 3 65 3 66 3 67 3 68 3 69 3 70 3 71 3 72 3 73 3 74 3 75 3 76 3 77 3 78 3 79 3 80 3 81 3 82 3 83 3 84 3 85 3 86 3 87 3 88 3 89 3 90 3 91 3 92 3 93 3 94 3 95 3 96 3 97 3 98 3 99 3 100 3 101 3 102 3 103 3 104 3 105 3 106 3 107 3 108 3 109 3 110 3 111 3 112 3 113 3 114 3 115 3 116 3 117 3 118 3 119 3 120 3 121 3 122 3 123 3 124 3 125 3 126 3 127 3 128 3 129 3 130 3 131 3 132 4 5 4 6 4 7 4 8 4 9 4 10 4 11 4 12 4 13 4 14 4 15 4 16 4 17 4 18 4 19 4 20 4 21 4 22 4 23 4 24 4 25 4 26 4 27 4 28 4 29 4 30 4 31 4 32 4 33 4 34 4 35 4 36 4 37 4 38 4 39 4 40 4 41 4 42 4 43 4 44 4 45 4 46 4 47 4 48 4 49 4 50 4 51 4 52 4 53 4 54 4 55 4 56 4 57 4 58 4 59 4 60 4 61 4 62 4 63 4 64 4 65 4 66 4 67 4 68 4 69 4 70 4 71 4 72 4 73 4 74 4 75 4 76 4 77 4 78 4 79 4 80 4 81 4 82 4 83 4 84 4 85 4 86 4 87 4 88 4 89 4 90 4 91 4 92 4 93 4 94 4 95 4 96 4 97 4 98 4 99 4 100 4 101 4 102 4 103 4 104 4 105 4 106 4 107 4 108 4 109 4 110 4 111 4 112 4 113 4 114 4 115 4 116 4 117 4 118 4 119 4 120 4 121 4 122 4 123 4 124 4 125 4 126 4 127 4 128 4 129 4 130 4 131 4 132 5 6 5 7 5 8 5 9 5 10 5 11 5 12 5 13 5 14 5 15 5 16 5 17 5 18 5 19 5 20 5 21 5 22 5 23 5 24 5 25 5 26 5 27 5 28 5 29 5 30 5 31 5 32 5 33 5 34 5 35 5 36 5 37 5 38 5 39 5 40 5 41 5 42 5 43 5 44 5 45 5 46 5 47 5 48 5 49 5 50 5 51 5 52 5 53 5 54 5 55 5 56 5 57 5 58 5 59 5 60 5 61 5 62 5 63 5 64 5 65 5 66 5 67 5 68 5 69 5 70 5 71 5 72 5 73 5 74 5 75 5 76 5 77 5 78 5 79 5 80 5 81 5 82 5 83 5 84 5 85 5 86 5 87 5 88 5 89 5 90 5 91 5 92 5 93 5 94 5 95 5 96 5 97 5 98 5 99 5 100 5 101 5 102 5 103 5 104 5 105 5 106 5 107 5 108 5 109 5 110 5 111 5 112 5 113 5 114 5 115 5\n", "1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60 1 61 1 62 1 63 1 64 1 65 1 66 1 67 1 68 1 69 1 70 1 71 1 72 1 73 1 74 1 75 1 76 1 77 1 78 1 79 1 80 1 81 1 82 1 83 1 84 1 85 1 86 1 87 1 88 1 89 1 90 1 91 1 92 1 93 1 94 1 95 1 96 1 97 1 98 1 99 1 100 1 101 1 102 1 103 1 104 1 105 1 106 1 107 1 108 1 109 1 110 1 111 1 112 1 113 1 114 1 115 1 116 1 117 1 118 1 119 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 25 2 26 2 27 2 28 2 29 2 30 2 31 2 32 2 33 2 34 2 35 2 36 2 37 2 38 2 39 2 40 2 41 2 42 2 43 2 44 2 45 2 46 2 47 2 48 2 49 2 50 2 51 2 52 2 53 2 54 2 55 2 56 2 57 2 58 2 59 2 60 2 61 2 62 2 63 2 64 2 65 2 66 2 67 2 68 2 69 2 70 2 71 2 72 2 73 2 74 2 75 2 76 2 77 2 78 2 79 2 80 2 81 2 82 2 83 2 84 2 85 2 86 2 87 2 88 2 89 2 90 2 91 2 92 2 93 2 94 2 95 2 96 2 97 2 98 2 99 2 100 2 101 2 102 2 103 2 104 2 105 2 106 2 107 2 108 2 109 2 110 2 111 2 112 2 113 2 114 2 115 2 116 2 117 2 118 2 119 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19 3 20 3 21 3 22 3 23 3 24 3 25 3 26 3 27 3 28 3 29 3 30 3 31 3 32 3 33 3 34 3 35 3 36 3 37 3 38 3 39 3 40 3 41 3 42 3 43 3 44 3 45 3 46 3 47 3 48 3 49 3 50 3 51 3 52 3 53 3 54 3 55 3 56 3 57 3 58 3 59 3 60 3 61 3 62 3 63 3 64 3 65 3 66 3 67 3 68 3 69 3 70 3 71 3 72 3 73 3 74 3 75 3 76 3 77 3 78 3 79 3 80 3 81 3 82 3 83 3 84 3 85 3 86 3 87 3 88 3 89 3 90 3 91 3 92 3 93 3 94 3 95 3 96 3 97 3 98 3 99 3 100 3\n", "1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1\n", "22 1 23 1 24 1 25 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 25 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19 3 20 3 21 3 22 3 23 3 24 3 25 4 5 4 6 4 7 4 8 4\n", "2 1 3 1 4 1 5 2 3 2 4 2\n", "16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 25 2 26 2 27 2 28 2 29 2 30 2 31 2 32 2 33 2 34 2 35 2 36 2 37 2 38 2 39 2 40 2 41 2 42 2 43 2 44 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 3 19 3 20 3 21 3 22 3 23 3 24 3 25 3 26 3 27 3 28 3 29 3 30 3 31 3 32 3 33 3 34 3 35 3 36 3 37 3 38 3 39 3 40 3 41 3 42 3 43 3 44 4 5 4 6 4 7 4 8 4 9 4 10 4 11 4 12 4 13 4 14 4 15 4 16 4 17 4 18 4 19 4 20 4 21 4 22 4 23 4 24 4 25 4 26 4 27 4 28 4 29 4 30 4 31 4 32 4 33 4 34 4 35 4 36 4 37 4 38 4 39 4 40 4 41 4 42 4 43 4 44 5 6 5 7 5 8 5 9 5 10 5 11 5 12 5 13 5 14 5 15 5 16 5 17 5 18 5 19 5 20 5 21 5 22 5 23 5 24 5 25 5 26 5 27 5 28 5 29 5 30 5 31 5 32 5 33 5 34 5 35 5 36 5 37 5 38 5 39 5 40 5 41 5 42 5 43 5 44 6 7 6 8 6 9 6 10 6 11 6 12 6 13 6 14 6 15 6 16 6 17 6 18 6 19 6 20 6 21 6 22 6 23\n", "1 2 1\n3 2 3\n1\n", "3\n", "1 2 1 3 1 4 1\n", "3 1\n", "1 2 1 3 1\n", "1 2 1 3 1\n", "2 1\n", "3\n", "3 1 4 1\n", "1 2 1 3 1\n", "1 2 1 3 1\n", "1 12 1 13 1 14 1 15 1 16 1 17 1\n" ] }
2CODEFORCES
Below is a problem description that describes the problem. Write code in Python that appropriately solves the problem. ### Description: You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of n(n - 1) + 1 vertices v_1, v_2, v_3, ..., v_{n(n - 1) - 1}, v_{n(n - 1)}, v_{n(n - 1) + 1} = v_1 β€” a visiting order, where each (v_i, v_{i + 1}) occurs exactly once. Find the lexicographically smallest such cycle. It's not hard to prove that the cycle always exists. Since the answer can be too large print its [l, r] segment, in other words, v_l, v_{l + 1}, ..., v_r. Input The first line contains the single integer T (1 ≀ T ≀ 100) β€” the number of test cases. Next T lines contain test cases β€” one per line. The first and only line of each test case contains three integers n, l and r (2 ≀ n ≀ 10^5, 1 ≀ l ≀ r ≀ n(n - 1) + 1, r - l + 1 ≀ 10^5) β€” the number of vertices in K_n, and segment of the cycle to print. It's guaranteed that the total sum of n doesn't exceed 10^5 and the total sum of r - l + 1 doesn't exceed 10^5. Output For each test case print the segment v_l, v_{l + 1}, ..., v_r of the lexicographically smallest cycle that visits every edge exactly once. Example Input 3 2 1 3 3 3 6 99995 9998900031 9998900031 Output 1 2 1 1 3 2 3 1 Note In the second test case, the lexicographically minimum cycle looks like: 1, 2, 1, 3, 2, 3, 1. In the third test case, it's quite obvious that the cycle should start and end in vertex 1. ### Input: 3 2 1 3 3 3 6 99995 9998900031 9998900031 ### Output: 1 2 1 1 3 2 3 1 ### Input: 1 2 2 3 ### Output: 2 1 ### Code: # -*- coding:utf-8 -*- """ created by shuangquan.huang at 2020/7/1 """ import collections import time import os import sys import bisect import heapq from typing import List def solve(n, l, r): # 1, 2, 1, 3, ..., 1, n # 2, 3, 2, 4, ..., 2, n # ... # n-1, n # 1 lo, hi = 1, n while lo <= hi: k = (lo + hi) // 2 s = k * (2*n-1-k) if s < l: lo = k + 1 else: hi = k - 1 k = lo s = k * (2*n-1-k) b = k # [b, b+1, b, b+2, ..., b, n] row = [] for i in range(b+1, n+1): row.append(b) row.append(i) ans = row[l-s-1:] d = r-l+1 if len(ans) >= d: return ans[:d] while len(ans) < d: b += 1 row = [] for i in range(b + 1, n + 1): row.append(b) row.append(i) if not row: break ans += row ans.append(1) # print(ans[:d]) return ans[:d] if __name__ == '__main__': T = int(input()) ans = [] for ti in range(T): N, L, R = map(int, input().split()) ans.append(solve(N, L, R)) print('\n'.join([' '.join(map(str, v)) for v in ans]))

Dataset Card for Code Contest Processed

Dataset Summary

This dataset contains coding contest questions and their solution written in Python3. This dataset is created by processing code_contest dataset from Deepmind. It is a competitive programming dataset for machine-learning. Read more about dataset at original source.

Columns Description

  • id : unique string associated with a problem
  • description : problem description
  • code : one correct code for the problem
  • test_samples : contains inputs and their corresponding outputs for the problem
  • source : source of problem
  • prompt : alpaca style generated prompt for text generation
Downloads last month
144
Edit dataset card

Models trained or fine-tuned on iamtarun/code_contest_python3_alpaca