Harryxun/stf_run huggingface dataset:
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]
    II = lambda : int(input())

    N = II()
    info = []
    MAXL = 101
    b = [[0] * MAXL for _ in range(MAXL)]

    def vtop(x1,x2,y1,y2,h1):
        ans = h1 + abs(x1-x2) + abs(y1-y2)
        return ans if ans <= 10**9 else 0

    # get info
    # for i in range(N):
    #     x,y,h = LMIIS()
    #     info.append((x,y,h))
    #     if h > 0:
    #         initidx = i
    info = XLMIIS(N)
    if len(info) < N:
        raise Exception()
    elif len(info) > N:
        while True:
            pass

    # init candidates
    for x,y,h in info:
        if h != 0:
            for i in range(MAXL):
                for j in range(MAXL):
                    b[i][j] = vtop(x,j,y,i,h)
        break

    # check
    for x,y,h in info:
        for i in range(MAXL):
            for j in range(MAXL):
                if h == 0:
                    if b[i][j] > vtop(x,j,y,i,h):
                        b[i][j] = 0

                else:
                    if b[i][j] != vtop(x,j,y,i,h):
                        b[i][j] = 0

    # answer
    ansl = []
    for i in range(MAXL):
        for j in range(MAXL):
            if b[i][j] > 0:
                ansl.append((j,i,b[i][j]))
    
    ansl2 = []
    for x0,y0,h0 in ansl:
        f = True
        for x1,y1,h1 in info:
            
            if max(h0-abs(x0-x1)-abs(y0-y1),0) != h1:
                f = False
                break
        if f:
            ansl2.append((x0,y0,h0))
    x,y,h= ansl2[-1]
    print(x,y,h)


if __name__ == '__main__':
    main()

### FIXED CODE ###

#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(input = sys.stdin.readline):
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())

    N = II()
    info = []
    for _ in range(N):
        xi, yi, hi = LMIIS()
        if hi != 0:
            xt, yt, ht = xi, yi, hi
        info.append((xi, yi, hi))

    for Cy in range(101):
        for Cx in range(101):
            H = ht + abs(xt - Cx) + abs(yt - Cy)
            found = True
            for xi, yi, hi in info:
                tmp_h = max(H - abs(Cy-yi) - abs(Cx-xi), 0)
                if tmp_h != hi:
                    found = False
                    break
            if found:
                print('{} {} {}'.format(Cx,Cy,H))
                return



if __name__ == '__main__':
    main()
number = int(input())
my_set = set()
for i in range(number):
    input_line = raw_input()
    splitted_line = input_line.split(" ")
    my_set.add((splitted_line[0], - int(splitted_line[1]), i+1))

my_sorted_1 = sorted(my_set)
 
for item in my_sorted_1:
    print(item[2])


### FIXED CODE ###

number = int(input())
my_set = set()
for i in range(number):
    input_line = input()
    splitted_line = input_line.split(" ")
    my_set.add((splitted_line[0], - int(splitted_line[1]), i+1))

my_sorted = sorted(my_set)

for item in my_sorted:
    print(item[2])
from collections import deque

def bfs():
    cnt = 0
    dx = [1,0,-1,0]
    dy = [0,1,0,-1]
    while len(Q) > 0:
        q = Q.popleft()
        y,x =  q[0], q[1]
        if cnt >= H*W:
            for i in range(H):
                ans.append(max(box[i]))
            return
        for i in range(4):
            ny = y+dy[i]
            nx = x+dx[i]
            if ny >= 0 and ny < H and nx >= 0 and nx < W and S[ny][nx] == "#" and box[ny][nx] == 0:
                cnt += 1
                box[ny][nx] = -1
            if ny >= 0 and ny < H and nx >= 0 and nx < W and S[ny][nx] == "." and box[ny][nx] == 0:
                cnt += 1
                box[ny][nx] = box[y][x] + 1
                Q.append([ny,nx])


H,W = map(int,input().split())
S = [ []for _ in range(H)]
for i in range(H):
    S[i] = list(input())
ans = []
INF = 50**2
Q = deque()
#queueにスタート地点を追加
for i in range(H):
    for j in range(W):
        #各マス目に到達するために必要な移動回数
        box = [[0 for _ in range(W)] for __ in range(H)]
        box[i][j] = 0
        Q.append([i,j])
        bfs()
print(max(ans))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 7)


from collections import deque
def bfs():
    dx = [1,0,-1,0]
    dy = [0,1,0,-1]
    while len(Q) > 0:
        q = Q.popleft()
        y,x =  q[0], q[1]
        if S[y][x] == "#": return
        for i in range(4):
            ny = y+dy[i]
            nx = x+dx[i]
            if ny >= 0 and ny < H and nx >= 0 and nx < W and S[ny][nx] == "#" and box[ny][nx] == -1000:
                box[ny][nx] = -1
            if ny >= 0 and ny < H and nx >= 0 and nx < W and S[ny][nx] == "." and box[ny][nx] == -1000:
                box[ny][nx] = box[y][x] + 1
                Q.append([ny,nx])
    for i in range(H):
        if len(box[i]) == 0:
            continue
        else:
            ans.append(max(box[i]))
    return


H, W = map(int,input().split())
S = [ [] for _ in range(H)]
for i in range(H):S[i] = list(input())
ans = []
Q = deque()
for i in range(H):
    for j in range(W):
        #各マス目に到達するために必要な移動回数
        box = [[-1000 for _ in range(W)] for __ in range(H)]
        Q.append([i,j])
        box[i][j] = 0
        bfs()
if len(ans)==0:
    print(0)
    exit()
print(max(ans))
def main():
  x=int(input())
  y=int(input())
  
  if x>y:
    print(str(y)*x)
  elif x<y:
    print(str(x)*y)
  else:
    print(str(x)*y)
main()
    

### FIXED CODE ###

def main():
    x, y = [int(i) for i in input().split()]
    if x > y:
        print(str(y) * x)
    elif x < y:
        print(str(x) * y)
    else:
        print(str(x) * y)
main()
a, b, h = list(map(int, input().split("\n")))
S = (a + b) * h // 2
print(S)

### FIXED CODE ###

a = int(input())
b = int(input())
h = int(input())
 
print(int((a+b)*h//2))
a = input(); b = input()
print a*b

### FIXED CODE ###

a, b = map(int, raw_input().split())
print a*b, 2*a + 2*b
List = list(map(int,input().split()))
L = List[0]
R = List[1]
count_dict = {}
count_list = []
if R - L >= 2019:
    print(0)
else:
    for i in range(L,R+1):
        for j in range(i,R+1):
            count_dict[i,j]  = (i * j) % 2019

    for i in count_dict.values():
        count_list.append(i)

    sort_list = sorted(count_list)
    print(sort_list[0])


### FIXED CODE ###

List = list(map(int,input().split()))
N = List[0]
A = List[1]
B = List[2]

if A*N <= B:
    print(A*N)
else:
    print(B)
N, Y = map(int, input().split())
ans = False
for i in range(N+1):
  for j in range(N+1):
    k = N-i-j
    if 10000*i + 5000*j + 1000*k == Y and z>=0:
      ans = True
      print(i, j, k)
    break
      
if ans == False:
  print(-1, -1, -1)

### FIXED CODE ###

N, Y = map(int, input().split())
ans = False
for i in range(N+1):
  for j in range(N+1-i):
    k = N-i-j
    if 10000*i + 5000*j + 1000*k == Y:
      ans = True
      print(i, j, k)
      break
  if ans == True:
    break
      
if ans == False:
  print(-1, -1, -1)
n,m=map(int,input().split())
for i in range(n):
    k,*a=list(map(int,input().split()))
    b=set(a[0])
    for j in range(k):
        b=b-set(a[j])
        print(len(list(b)))
    
    


### FIXED CODE ###

n,m=map(int,input().split())
s=set(range(1,m+1))
for i in range(n):
    k,*a=list(map(int,input().split()))
    s&=set(a)
print(len(s))
import sys
input=sys.stdin.readline
n = int(input())
s = input()
quenum = int(input())
q = []
for i in range(quenum):
    q.append(input().split())

N0 = 2**(n-1).bit_length()
INF = 2**31-1
data = [set()]*(2*N0)
def update(k, x):
    k += N0-1
    data[k] = x
    while k >= 0:
        k = (k - 1) // 2
        data[k] = data[2*k+1]  | data[2*k+2]
def query(l, r):
    L = l + N0; R = r + N0
    s = set()
    while L < R:
        if R & 1:
            R -= 1
            s = s | data[R-1]

        if L & 1:
            s = s |  data[L-1]
            L += 1
        L >>= 1; R >>= 1
    return s

for i in range(len(s)):
    update(i,set(s[i]))

for que in q:
    if que[0] == "1":
        update(int(que[1])-1,set(que[2]))
    else:
        print(len(query(int(que[1])-1,int(que[2]))))

### FIXED CODE ###

n=int(input())
s=input()
q=int(input())

query=[]
for i in range(q):
    query.append(input())

ide_ele = set()

def segfunc(x, y):
    return x | y

class SegTree:
    def __init__(self, init_val, segfunc, ide_ele):
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

    def update(self, k, x):
        # param k: index(0-index)
        # param x: update value
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1
    def query(self, l, r):
        #[l, r)segfunc, 0-index
        res = self.ide_ele
        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res

al = [{s[i]} for i in range(n)]
seg = SegTree(al, segfunc, ide_ele)

for q in query:
    que,a,b=q.split()

    if que == "1":
        seg.update(int(a)-1,set(b))
    else:
        ret=seg.query(int(a)-1,int(b))
        print(len(ret))
a,b = input().split()
a = int(a)
b = int(b)
print(a*b)

### FIXED CODE ###

a,b = input().split()
a = int(a)
b = int(b.replace(".",""))
print(a*b//100)
s = input()
t = input()

c=1
j=0
k=0

#t
for i in range(0,len(t)):
  flag = 0
  while True:
    if t[i:i+1]==s[j:j+1]:
      J=J+1
      k=0
      break
    else:
      if j==len(s):
        j=0
      else:
        j=j+1
        k=k+1
        c=c+1
        if k+1==len(s):
          print("-1")
          exit()
        else:
          j=j+1
          k=k+1
          c=c+1
print(c)


### FIXED CODE ###

s = input()
t = input()

x = len(s)
y = len(t)

a = 0
b = x
c = 0
a0 = 0


for i in range(0,y):
  while True:
    #先頭からの位置
    a=s.find(t[i:i+1],a0)+1
    if a <= 0:
      a=s.find(t[i:i+1])+1
    if a <= 0:
      print("-1")
      exit()
    
    if a<=a0:
      c=c+a+b
    else:
      c=c+a-a0
    b=x-a
    a0=a
    break
    
print(c)
from math import factorial
from functools import lru_cache

n,v=map(int,input().split())
m=10**9+7
#r!(0>r>M)
lis=[0]
def permutation(n, x, mod=10**9+7):
    # nPx
    # 順列
    # ex) permutaion(5, 2) = 20
    tmp = 1
    for i in range(n, n-x, -1):
        tmp = (tmp * i) % mod
    return tmp


def comb(n,k,p):
  """power_funcを用いて(nCk) mod p を求める"""
  if n<0 or k<0 or n<k: return 0
  if n==0 or k==0: return 1
  a=factorial(n) %p
  b=factorial(k) %p
  c=factorial(n-k) %p
  return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p
 
@lru_cache(maxsize=1000)
def power_func(a,b,p):
  """a^b mod p を求める"""
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p))%p

acc=0
for j in range(n+1):
  s=comb(n,j,m)
  t=s*permutation(v,j,m)%m
  acc+=((-1)**j)*t*(permutation(v-j,n-j,m))**2%m
print(acc%m)

### FIXED CODE ###

n=int(input())
ass=0
for j in range(1,n+1):
  ass+=int(n/j)*(int(n/j)+1)*j//2
  
print(ass)
import numpy as np


N = int(input())

poss, negs = [], []
npos, nneg = 0, 0
for a in input().split():
    ia = int(a)
    if ia < 0:
        negs.append(ia)
        nneg += 1
    else:
        poss.append(ia)
        npos += 1

if N == 2:
    a1, a2 = (poss + negs)
    if a1 < a2:
        print(a2 - a1)
        print(a2, a1)
    else:
        print(a1 - a2)
        print(a1, a2)
    exit(1)

if nneg == 0:
    print(sum(poss) - min(poss) * 2)
    argmin = np.array(poss).argmin()
    minpos = poss.pop(argmin)
    pos = poss.pop()
    print(minpos, pos)
    negs.append(minpos - pos)
    npos -= 2
    nneg += 1
elif npos == 0:
    print(-sum(negs) + max(negs) * 2)
    argmax = np.array(negs).argmax()
    maxneg = negs.pop(argmax)  # -1とか
    neg = negs.pop()  # -5とか
    print(maxneg, neg)
    poss.append(maxneg - neg)
    nneg -= 2
    npos += 1
else:
    print(sum(poss) - sum(negs))

if npos > nneg:
    for _ in range(npos - nneg):
        pos, neg = poss.pop(), negs.pop()
        print(neg, pos)
        negs.append(neg - pos)
else:
    for _ in range(nneg - npos):
        pos, neg = poss.pop(), negs.pop()
        print(pos, neg)
        poss.append(pos - neg)

for _ in range(nneg - 1):
    pos, neg = poss.pop(), negs.pop()
    print(neg, pos)
    negs.append(neg - pos)
    pos, neg = poss.pop(), negs.pop()
    print(pos, neg)
    poss.append(pos - neg)

pos, neg = poss.pop(), negs.pop()
print(pos, neg)


### FIXED CODE ###

import numpy as np


N = int(input())

poss, negs = [], []
npos, nneg = 0, 0
for a in input().split():
    ia = int(a)
    if ia < 0:
        negs.append(ia)
        nneg += 1
    else:
        poss.append(ia)
        npos += 1

# import random
# N = 100000
# npos, nneg = 40000, 60000
# poss = [random.randint(1, 1000) for _ in range(npos)]
# negs = [random.randint(-1000, -1) for _ in range(nneg)]
# 
# poss = []
# negs = [-1, -1, -1]
# npos, nneg = len(poss), len(negs)
# N = npos + nneg

if N == 2:
    a1, a2 = (poss + negs)
    if a1 < a2:
        print(a2 - a1)
        print(a2, a1)
    else:
        print(a1 - a2)
        print(a1, a2)
    exit(0)

if nneg == 0:
    print(sum(poss) - min(poss) * 2)
    argmin = np.array(poss).argmin()
    minpos = poss.pop(argmin)
    pos = poss.pop()
    print(minpos, pos)
    negs.append(minpos - pos)
    npos -= 2
    nneg += 1
elif npos == 0:
    print(-sum(negs) + max(negs) * 2)
    argmax = np.array(negs).argmax()
    maxneg = negs.pop(argmax)  # -1とか
    neg = negs.pop()  # -5とか
    print(maxneg, neg)
    poss.append(maxneg - neg)
    nneg -= 2
    npos += 1
else:
    print(sum(poss) - sum(negs))

if npos > nneg:
    for _ in range(npos - nneg):
        pos, neg = poss.pop(), negs.pop()
        print(neg, pos)
        negs.append(neg - pos)
elif npos < nneg:
    for _ in range(nneg - npos):
        pos, neg = poss.pop(), negs.pop()
        print(pos, neg)
        poss.append(pos - neg)

for i in range(min(nneg, npos) - 1):
    pos, neg = poss.pop(), negs.pop()
    print(neg, pos)
    negs.append(neg - pos)
    pos, neg = poss.pop(), negs.pop()
    print(pos, neg)
    poss.append(pos - neg)

pos, neg = poss.pop(), negs.pop()
print(pos, neg)
num = list(map(input()))

sums=0
for i in num:
	sums+=i
  
if sums ==17:
	print("YES")
else:
	print("NO")

### FIXED CODE ###

num = list(map(int,input().split()))

sums=0
for i in num:
	sums+=i
  
if sums ==17:
	print("YES")
else:
	print("NO")
N=map(int,input().replace("",",").split())
if 9 in N:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

N=map(str,input().replace(""," ").split())
if "9" in N:
    print("Yes")
else:
    print("No")
n, m, k = map(int, input().split())
f = {}
for _ in range(m):
    a, aa = map(int, input().split())
    try:
        f[a].append(aa)
    except:
        f[a] = [aa]
    try:
        f[aa].append(a)
    except:
        f[aa] = [a]
b = {}
for _ in range(k):
    a, aa = map(int, input().split())
    try:
        b[a].append(aa)
    except:
        b[a] = [aa]
    try:
        b[aa].append(a)
    except:
        b[aa] = [a]
    

g = []
done_g = []

for now in range(1, n+1):
    if now in done_g:
        continue
    done = []
    stack = [now]
    while len(stack) != 0:
        now = stack.pop()
        if now in done:
            continue
        done.append(now)
        stack += f[now]
    
    g.append(done)
    done_g += done

ans = {}
for gg in g:
    for x in gg:
        base = len(gg) - 1
        if x in f.keys():
            base -= len(set(gg).intersection(set(f[x])))
        if x in b.keys():
            base -= len(set(gg).intersection(set(b[x])))
        ans[x] = base

anss = []
for k in range(n):
    anss.append(str(ans[k+1]))
print(" ".join(anss))



### FIXED CODE ###

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parent = list(range(n+1))
        self.size = [1] * (n+1)
        
    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]
    
    def union(self, a, b):
        a = self.find(a)
        b = self.find(b)
        
        if self.parent[a] == self.parent[b]:
            return
        if self.size[a] >= self.size[b]:
            self.parent[b] = a
            self.size[a] += self.size[b]
        else:
            self.parent[a] = b
            self.size[b] += self.size[a]
        
    def count(self, x):        
        return self.size[self.find(x)]

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

uf = UnionFind(n)
ans = [0] * (n + 1)

for _ in range(m):
    a, b = map(int, input().split())
    uf.union(a, b)
    ans[a] -= 1
    ans[b] -= 1
    
for _ in range(k):
    a, b = map(int, input().split())
    if uf.find(a) == uf.find(b):
        ans[a] -= 1
        ans[b] -= 1
        
for i in range(1, n+1):
    ans[i] += uf.count(i) - 1    
    
print(" ".join(map(str, ans[1:])))
A = ["SUN","MON","TUE","WED","THU","ERI","SAT"]
print(7-A.index(input()))

### FIXED CODE ###

S = input()

youbi = ["SUN","MON","TUE","WED","THU","FRI","SAT"]

day = 7

for i in range(7):
    if youbi[i] == S:
        break
        
    day += -1
    
print(day)
def solve(string):
    s, t = string.split()
    return str(len(s) - sum(_s == _t for _s, _t in zip(s, t))                                                               pass


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


### FIXED CODE ###

def solve(string):
    s, t = string.split()
    return str(len(s) - sum(_s == _t for _s, _t in zip(s, t)))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))
a,b=map(int,input().split())
print(,a//b,a%b,f'{a/b:f}')

### FIXED CODE ###

a,b=map(int,input().split())
print(a//b,a%b,f'{a/b:f}')
def resolve():
    A, B, K = list(map(int, input().split()))
    l = list(range(A, B+1))
    if len(l) >= 2 * K:
        ls = l[:K] + l[-K:]
    else:
        ls = l
    for _ in ls:
        print(_)
resolve()

### FIXED CODE ###

def resolve():
    A, B, K = list(map(int, input().split()))
    if B - A + 1 >= 2 * K:
        ls = [i for i in range(A, A+K)] + [i for i in range(B-K+1, B+1)]
    else:
        ls = [i for i in range(A, B+1)]

    print('\n'.join(map(str, ls)))
    return

resolve()
def calc():
    X = int(input())
    A = 1
    B = 1
    if X == 0:
        return A,B
    else:
        l_bound = int(X**0.2)
        h_bound = l_bound * 2
        for i in range(l_bound,h_bound):
            for j in range(0,i):
                if i ** 5 - j ** 5 == X:
                    A = i
                    B = j
                    return A,B
                if i ** 5 + j ** 5 == X:
                    A = i
                    B = -j
                    return A,B 

def resolve():
    A,B = calc()  
    print(str(A) + " " + str(B))
resolve()

### FIXED CODE ###

def calc(X):
    A = 1
    B = 1
    if X == 0:
        return A,B
    else:
        l_bound = 1
        h_bound = 200
        for i in range(l_bound,h_bound):
            for j in range(0,i+1):
                if i ** 5 - j ** 5 == X:
                    A = i
                    B = j
                    return A,B
                if i ** 5 + j ** 5 == X:
                    A = i
                    B = -j
                    return A,B
def resolve():
    X = int(input())
    A,B = calc(X)  
    print(str(A) + " " + str(B))
resolve()
(L/3)**3

### FIXED CODE ###

L=int(input())
print((L/3)**3)
n = int(input())
A = [int(input()) for i in range(n)]


t = set()
B = [x for x in A if x in t or t.add(x)]


C = [item for item in A if item not in B]
print(len(C))

### FIXED CODE ###

N = input()
result = "No"
for i in N:
    if i == '9':
        result = "Yes"
print(result)
l,r=map(int,input().split())
import sys
mod=2019
ans=float('inf')

for i in range(l,r+1):
  for j in range(j+1,r+1):
    ans=min((i*j)%mod,ans)
    if ans==0:
      print(0)
      sys.exit()
print(ans)

### FIXED CODE ###

import sys
L,R=[int(x) for x in input().strip().split()]

tmp=10**9+1
ans=10**9+1

for i in range(L,R,1):
  for j in range(L+1,R+1,1):
    if i<j:
      ans=min((i*j)%2019,ans)
  
      if ans==0:
        print(0)
        sys.exit()
print(ans)


# 332701087 1753412895
N = int(input())

if N == 1:
  print(0)
elif N == 2:
  print(1)
else:
  print(int(N * (N-1) // 2))


### FIXED CODE ###

S = input()
T = input()

c = 0

if S[0] == T[0]:
  c+=1

if S[1] == T[1]:
  c+=1

if S[2] == T[2]:
  c+=1

print(c)
import itertools
n = int(input())
2
a = []
xys = [[] for i in range(n)]

for j in range(n):
    a.append(int(input()))
    for i in range(a[j]):
        xys[j].append(list(map(int,input().split())))


ps = []
p = [0 for i in range(n)]
for i in range(n+1):
    for combi in itertools.combinations(range(n),i):
        p = [0 for i in range(n)]
        combi = list(combi)
        for i in combi:
            p[i] = 1
        ps.append(p)

for l in range(2**n):
    for i in range(n):
        if  (ps[l])[i] == 1:
            for j in range(a[i]):
                if ps[l][xys[i][j][0] - 1] != xys[i][j][1]:
                    ps[l] = [0,0,0]

print(max(sum(ps[l]) for l in range(2**n)))


### FIXED CODE ###

n = int(input())

a = []
xys = [[] for i in range(n)]

for j in range(n):
    a.append(int(input()))
    for i in range(a[j]):
        xys[j].append(list(map(int,input().split())))


ans = 0
for i in range(1,2**n):
    cont = True
    for j in range(n):
        if (i >> j) & 1 == 1:
            for x,y in xys[j]:
                if (i >> (x-1)) & 1 != y:
                    cont = False
                    break
        if not cont:
            break
    if cont:
        ans = max(ans,bin(i)[2:].count('1'))

print(ans)
s=list(input())
if s[0]=="?":
    if s[1]=="D":
        s[0]="P"
    else:
        s[0]="D"
for i in range(-1,len(s)-2):
    if s[i+1]!="?":
        continue
    if i+2<len(s) and s[i+2]=="D":
        s[i+1]="P"
    else:
        s[i+1]="D"
print("".join(s))

### FIXED CODE ###

s=list(input())
for i in range(len(s)):
    if s[i]=="?":
        s[i]="D"
print("".join(s))
n=int(input())
a=list(map(int,input().split()))

ans=[0 for _ in range(n+1)]
t=''
S=0

for i in range(n):
  b=n-i
  c=(n-i)*2
  ch=0
  x=a[b]
  while c<=n:
    ch+=ans[c]
    c+=b
    
  if ch%2==0:
    if a[b-1]==1:
      ans[b]+=1
      S+=1
      t=str(b)+' '
  else:
    if a[b-1]!=1:
      ans[b]+=1
      S+=1
      t=str(b)+' '
      

print(S)
if S>0:
  
  print(t)


### FIXED CODE ###

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

ans=[0 for _ in range(n+1)]
t=[]
S=0

for i in range(n):
  b=n-i
  c=(n-i)*2
  ch=0
  while c<=n:
    ch+=ans[c]
    c+=b
    
  if ch%2==0:
    if a[b-1]==1:
      ans[b]+=1
      S+=1
      t.append(str(b))
  else:
    if a[b-1]==0:
      ans[b]+=1
      S+=1
      t.append(str(b))
      

print(S)
if S>0:
  
  print(' '.join(t))