CodeEff/ECCO huggingface dataset:
# Original solution
N=int(eval(input()))
A=[]
PRECISION_DIGITS=9
cnt={}


for n in range(N):
	tmpA = float(eval(input()))
	tmpA = round(tmpA*(10**PRECISION_DIGITS))
	#print(tmpA)

	two = 0
	five = 0
	while (tmpA % 2) == 0:
		two += 1
		tmpA /= 2
	while (tmpA % 5) == 0:
		five += 1
		tmpA /= 5

	if (two,five) in cnt:
		cnt[(two,five)]+=1
	else:
		cnt[(two,five)]=1

keys=sorted(cnt.keys())
# print(keys)
ans = 0
for t1 in keys:
	for t2 in keys:
		# 2**a(a>=0) and 5**b(b>=0) => integer
		if 18 <= t1[0]+t2[0] and 18 <= t1[1]+t2[1]:
			cnt1 = cnt[(t1[0],t1[1])]
			cnt2 = cnt[(t2[0],t2[1])]
			if t1 < t2:
				ans += int(cnt1*cnt2)
			elif t1 == t2:
				# same entry
				# Total number of combinations choose 2 items
				# nC2 = n*(n-1)/2
				ans += int(cnt1*(cnt1-1)/2)


print(ans)



# Optimized solution
N=int(eval(input()))
A=[]
PRECISION_DIGITS=9
cnt={}


for n in range(N):
	tmpA = float(eval(input()))
	tmpA = round(tmpA*10**PRECISION_DIGITS)
	#print(tmpA)

	five = 0
	two = 0
	while (tmpA % 2) == 0:
		two += 1
		tmpA //= 2
	while (tmpA % 5) == 0:
		five += 1
		tmpA //= 5

	# (10**9) -> (two,five)=(9,9)
	two -= PRECISION_DIGITS
	five -= PRECISION_DIGITS

	if (two,five) in cnt:
		cnt[(two,five)]+=1
	else:
		cnt[(two,five)]=1

# print(cnt)
ans = 0
for t1, cnt1 in list(cnt.items()):
	for t2, cnt2 in list(cnt.items()):
		# 2**a(a>=0) and 5**b(b>=0) => integer
		if 0 <= t1[0]+t2[0] and 0 <= t1[1]+t2[1]:
			if t1 < t2:
				ans += int(cnt1*cnt2)
			elif t1 == t2:
				# same entry
				# Total number of combinations choose 2 items
				# nC2 = n*(n-1)/2
				ans += int((cnt1*(cnt2-1))/2)


print(ans)
# Original solution
import collections

N=int(eval(input()))
A=[]
PRECISION_DIGITS=9
cnt=collections.defaultdict(int)


for n in range(N):
	tmpA = float(eval(input()))
	tmpA = round(tmpA*10**PRECISION_DIGITS)
	#print(tmpA)

	five = 0
	two = 0
	while (tmpA % 2) == 0:
		two += 1
		tmpA //= 2
	while (tmpA % 5) == 0:
		five += 1
		tmpA //= 5

	# (10**9) -> (two,five)=(9,9)
	two -= PRECISION_DIGITS
	five -= PRECISION_DIGITS

	cnt[(two,five)]+=1

# print(cnt)
ans = 0
for t1, cnt1 in list(cnt.items()):
	for t2, cnt2 in list(cnt.items()):
		# 2**a(a>=0) and 5**b(b>=0) => integer
		if 0 <= t1[0]+t2[0] and 0 <= t1[1]+t2[1]:
			if t1 < t2:
				ans += int(cnt1*cnt2)
			elif t1 == t2:
				# same entry
				# Total number of combinations choose 2 items
				# nC2 = n*(n-1)/2
				ans += int((cnt1*(cnt2-1))/2)


print(ans)



# Optimized solution
# import collections

N=int(eval(input()))
A=[]
PRECISION_DIGITS=9
cnt={} #collections.defaultdict(int)


for n in range(N):
	tmpA = float(eval(input()))
	tmpA = round(tmpA*10**PRECISION_DIGITS)
	#print(tmpA)

	five = 0
	two = 0
	while (tmpA % 2) == 0:
		two += 1
		tmpA //= 2
	while (tmpA % 5) == 0:
		five += 1
		tmpA //= 5

	# (10**9) -> (two,five)=(9,9)
	two -= PRECISION_DIGITS
	five -= PRECISION_DIGITS

	cnt.setdefault((two,five),0)
	cnt[(two,five)]+=1

# print(cnt)
ans = 0
for t1, cnt1 in list(cnt.items()):
	for t2, cnt2 in list(cnt.items()):
		# 2**a(a>=0) and 5**b(b>=0) => integer
		if 0 <= t1[0]+t2[0] and 0 <= t1[1]+t2[1]:
			if t1 < t2:
				ans += int(cnt1*cnt2)
			elif t1 == t2:
				# same entry
				# Total number of combinations choose 2 items
				# nC2 = n*(n-1)/2
				ans += int((cnt1*(cnt2-1))/2)


print(ans)
# Original solution
from decimal import Decimal
def waru(N,num):
  cnt = 0
  while N%num==0:
    N //= num
    cnt += 1
  return cnt
def solve():
  N = int(eval(input()))
  num = [[0]*101 for _ in range(101)]
  lis = [0]*N
  for i in range(N):
    a = int(round(float(eval(input()))*10**9))
    p,q = waru(a,2)-9-50,waru(a,5)-9-50
    num[p][q] += 1
    lis[i] = [p,q]
  cum2 = [[0]*101 for _ in range(101)]
  for i in range(99,-1,-1):
    for j in range(99,-1,-1):
      cum2[i][j] = cum2[i+1][j]+cum2[i][j+1]-cum2[i+1][j+1]+num[i][j]
  ans = 0
  for i in range(N):
    p,q = lis[i]
    x,y = p+50,q+50
    p = -x-50
    q = -y-50
    ans += cum2[p][q]
    if x>=0 and y>=0:
      ans -= 1
  return ans//2
print((solve()))

# Optimized solution
import sys
input = sys.stdin.readline
def waru(N,num):
  cnt = 0
  while N%num==0:
    N //= num
    cnt += 1
  return cnt
def solve():
  N = int(eval(input()))
  num = [[0]*101 for _ in range(101)]
  lis = [0]*N
  for i in range(N):
    a = int(round(float(eval(input()))*10**9))
    p,q = waru(a,2)-9-50,waru(a,5)-9-50
    num[p][q] += 1
    lis[i] = [p,q]
  cum2 = [[0]*101 for _ in range(101)]
  for i in range(99,-1,-1):
    for j in range(99,-1,-1):
      cum2[i][j] = cum2[i+1][j]+cum2[i][j+1]-cum2[i+1][j+1]+num[i][j]
  ans = 0
  for i in range(N):
    p,q = lis[i]
    x,y = p+50,q+50
    p = -x-50
    q = -y-50
    ans += cum2[p][q]
    if x>=0 and y>=0:
      ans -= 1
  return ans//2
print((solve()))
# Original solution
c=eval('[0]*50,'*50)
r=0
for a in[*open(0)][1:]:
 a=round(float(a)*10**9);x=y=0
 while a%2<1:a//=2;x+=1
 while a%5<1:a//=5;y+=1
 r+=sum(sum(d[max(0,18-y):])for d in c[max(0,18-x):]);c[x][y]+=1
print(r)

# Optimized solution
c=eval('[0]*50,'*50)
r=0
for a in[*open(0)][1:]:
 a=round(float(a)*1e9);x=y=0
 while a%2<1:a//=2;x+=1
 while a%5<1:a//=5;y+=1
 r+=sum(sum(d[max(0,18-y):])for d in c[max(0,18-x):]);c[x][y]+=1
print(r)
# Original solution
c=eval('[0]*50,'*50)
r=0
for a in[*open(0)][1:]:
 a=round(float(a)*1e9);x=y=1
 while a%2**x<1:x+=1
 while a%5**y<1:y+=1
 r+=sum(sum(d[max(0,20-y):])for d in c[max(0,20-x):]);c[x][y]+=1
print(r)

# Optimized solution
c=eval('[0]*50,'*50)
r=0
for a in[*open(0)][1:]:
 a=round(float(a)*1e9);y=1
 while a%5**y<1:y+=1
 x=len(bin(a&-a));r+=sum(sum(d[max(0,20-y):])for d in c[max(0,24-x):]);c[x][y]+=1
print(r)
# Original solution
from collections import defaultdict

def conv(s):
    if "." not in s:
        s += '.'
    s = s.rstrip('0')
    t = len(s) - s.find('.') - 1
    a = int(s.replace('.', ''))
    if a == 0:
        return (0, 0)
    x, y = -t, -t
    while a % 5 == 0:
        x += 1
        a //= 5
    y += len(bin(a&-a))-3
    return (x, y)

_, *A = open(0).read().split()

d = defaultdict(int)
for a in A:
    d[conv(a)] += 1

result = 0
d = list(d.items())
for i, ((x, y), cnt) in enumerate(d):
    if x >= 0 and y >= 0:
        result += cnt * (cnt - 1) // 2
    for (m, n), cnt2 in d[i+1:]:
        if x + m >= 0 and y + n >= 0:
            result += cnt * cnt2
print(result)


# Optimized solution
import sys
from collections import defaultdict
from math import gcd

def input(): return sys.stdin.readline().strip()

K = 10**9
L = 10**18
D = defaultdict(int)
for _ in range(int(eval(input()))):
    D[gcd(round(float(eval(input())) * K), L)] += 1

D = tuple(D.items())
ans = 0
for i, (k1, v1) in enumerate(D):
    if k1*k1 % L == 0:
        ans += v1*(v1-1) // 2
    for k2, v2 in D[i+1:]:
        if k1*k2 % L == 0:
            ans += v1 * v2
print(ans)
# Original solution
import bisect
from decimal import Decimal
N, *A = [Decimal(_) for _ in open(0).read().split()]
N = int(N)
c = [[0, 0] for _ in range(N)]
for i, a in enumerate(A):
    a = int(a * 10**9)
    while True:
        if a % 2:
            break
        c[i][0] += 1
        a //= 2
    while True:
        if a % 5:
            break
        c[i][1] += 1
        a //= 5
c.sort()

#cum[i][j]:c[x][1]>=i (j<=x)となるようなxの個数
cum = [[0] * (N + 1) for _ in range(19)]
for i in range(19):
    for j in range(N - 1, -1, -1):
        cum[i][j] = cum[i][j + 1]
        if c[j][1] >= i:
            cum[i][j] += 1
ans = 0
for i, c2c5 in enumerate(c):
    c2, c5 = c2c5
    if c2 > 9 or (c2 == 9 and c5 >= 9):
        i2 = i + 1
    else:
        i2 = bisect.bisect_left(c, [18 - c2, -1])
    ans += cum[18 - c5][i2]
print(ans)


# Optimized solution
import bisect
from decimal import Decimal
N, *A = open(0).read().split()
N = int(N)
c = [[0, 0] for _ in range(N)]
for i, a in enumerate(A):
    if '.' in a:
        p, q = a.split('.')
        q += '0' * (9 - len(q))
    else:
        p = a
        q = '0' * 9
    a = int(p + q)
    while True:
        if a % 2:
            break
        c[i][0] += 1
        a //= 2
    while True:
        if a % 5:
            break
        c[i][1] += 1
        a //= 5
c.sort()

#cum[i][j]:c[x][1]>=i (j<=x)となるようなxの個数
cum = [[0] * (N + 1) for _ in range(19)]
for i in range(19):
    for j in range(N - 1, -1, -1):
        cum[i][j] = cum[i][j + 1]
        if c[j][1] >= i:
            cum[i][j] += 1
ans = 0
for i, c2c5 in enumerate(c):
    c2, c5 = c2c5
    if c2 > 9 or (c2 == 9 and c5 >= 9):
        i2 = i + 1
    else:
        i2 = bisect.bisect_left(c, [18 - c2, -1])
    ans += cum[18 - c5][i2]
print(ans)
# Original solution
def div(n, d):
    cnt = 0
    while n % d == 0 and cnt < 18:
        n //= d
        cnt += 1
    return cnt


n = int(eval(input()))
dp = [[0]*19 for _ in range(19)]
#dp[i][j] -> 2の素因数がi以上,5の素因数がj以上の数字の数

ans = 0
for _ in range(n):
    x = round(float(eval(input())) * pow(10, 9))
    two = div(x, 2)
    five = div(x, 5)
    ans += dp[18 - two][18 - five]
    for i in range(two + 1):
        for j in range(five + 1):
            dp[i][j] += 1

print(ans)


# Optimized solution
"""
小数の状態だと処理しづらいので、与えられた数を全て10**9倍して小数を確実になくした上で
問題文を下記のように言い換える。
「積が10**18の倍数になるような数の組み合わせの数がいくつあるか」
数Aiがあり、Aiの2の素因数の数がn, 5の素因数の数がmのとき、
数Ai自体ですでにmin(n,m)個の0の数を持っている。この場合、のこり必要な0の数はx = 18-min(n,m)個である。
ここで、n == mの場合：
Aiの相方は少なくとも2,5の素因数をそれぞれx個以上持っていなくてはならない。
n > mの場合：
Aiの相方は少なくとも2の素因数をx-(n-m)個、5の素因数をx個持っていなくてはいけない。

m > nの場合：
Aiの相方は少なくとも2の素因数をx個以上、5の素因数をx-(m-n)個以上持っていなくてはならない。
"""
N = int(eval(input()))
dp = [[0]*(19) for _ in range(19)]
ans = 0
for _ in range(N):
    a = round(float(eval(input()))*pow(10,9))
    two = 0
    while a % 2 == 0 and two < 18:
        a //= 2
        two += 1
    five = 0
    while a % 5 == 0 and five < 18:
        a //= 5
        five += 1

    ans += dp[18-two][18-five]
    for i in range(two+1):
        for j in range(five+1):
            dp[i][j] += 1
print(ans)
# Original solution
import sys
readline = sys.stdin.readline

N = int(readline())

C = [[0] * 19 for i in range(19)]

for i in range(N):
  a = readline().rstrip()
  if "." in a:
    keta = len(a.split(".")[1])
    a = int(a.replace(".","")) * (10 ** (9 - keta))
  else:
    a = int(a) * (10 ** 9)
  temp = a
  cnt2 = 0
  cnt5 = 0
  while a % 2 == 0:
    a //= 2
    cnt2 += 1
  while a % 5 == 0:
    a //= 5
    cnt5 += 1
  C[min(cnt2, 18)][min(cnt5, 18)] += 1

#for c in C:
#  print(c)

ans = 0
# まず、同じグループから2つの数を選ぶ場合の数
for i in range(9, 19):
  for j in range(9, 19):
    n = C[i][j]
    ans += (n * (n - 1)) // 2

# 異なるグループから選ぶ場合の数
ans_diff = 0
for i in range(19):
  for j in range(19):
    for p in range(19):
      for q in range(19):
        if i == p and j == q:
          continue # カウント済
        if i + p < 18 or j + q < 18:
          continue
        ans_diff += C[i][j] * C[p][q]

ans += ans_diff // 2 # 二回カウントしている

print(ans)


# Optimized solution
import sys
readline = sys.stdin.readline

N = int(readline())

C = [[0] * 19 for i in range(19)]

for i in range(N):
  a = readline().rstrip()
  if "." in a:
    keta = len(a.split(".")[1])
    a = int(a.replace(".","")) * (10 ** (9 - keta))
  else:
    a = int(a) * (10 ** 9)
  cnt2 = 0
  cnt5 = 0
  while a % 2 == 0:
    a //= 2
    cnt2 += 1
  while a % 5 == 0:
    a //= 5
    cnt5 += 1
  C[min(cnt2, 18)][min(cnt5, 18)] += 1

#for c in C:
#  print(c)

ans = 0
# まず、同じグループから2つの数を選ぶ場合の数
for i in range(9, 19):
  for j in range(9, 19):
    n = C[i][j]
    ans += (n * (n - 1)) // 2

# 異なるグループから選ぶ場合の数
ans_diff = 0
for i in range(19):
  for j in range(19):
    for p in range(19):
      for q in range(19):
        if i == p and j == q:
          continue # カウント済
        if i + p < 18 or j + q < 18:
          continue
        ans_diff += C[i][j] * C[p][q]

ans += ans_diff // 2 # 二回カウントしている

print(ans)
# Original solution
a=[2,3,5,10,12,15]
b=[380,550,850,1520,1870,2244]
while 1:
    n=int(eval(input()))
    if n==0:break
    n//=100
    dp=[0]+[1<<29]*n
    for i in range(5,-1,-1):
        for j in range(n+1):
            if j+a[i]<=n and dp[j]!=1<<29:dp[j+a[i]]=min(dp[j+a[i]],dp[j]+b[i])
    print((dp[n]))

# Optimized solution
a=[(2,380),(3,550),(5,850),(10,1520),(12,1870),(15,2244)]
dp=[1<<20]*51
for i,j in a:
    dp[i]=j
    for k in range(51-i):
        if dp[k]!=1<<20 and dp[k+i]>dp[k]+j:
            dp[k+i]=dp[k]+j
while 1:
    n=int(eval(input()))
    if n==0:break
    print((dp[n//100]))
# Original solution
while True:
 N = int(eval(input()))
 if N==0: break
 ans = float('inf')
 for c200 in range(N//200+1):
  for c300 in range(N//300+1):
   for c500 in range(N//500+1):
    if 200 * c200 + c300 * 300 + c500 * 500 == N:
     ans = min(ans, 1520*(c200//5)+380*(c200%5)+1870*(c300//4)+550*(c300%4)+2244*(c500//3)+850*(c500%3))
 print(ans)


# Optimized solution
a=[1e4]*51
for i,j in[(2,380),(3,550),(5,850),(10,1520),(12,1870),(15,2244)]:
 a[i]=j
 for k in range(51-i):
  if a[k+i]>a[k]+j:a[k+i]=a[k]+j
for n in iter(input,'0'):print((a[int(n)//100]))
# Original solution
"""Rooted Trees."""

class Node:
    def __init__(self, num, parent, *children):
        self.id = num
        self.parent = parent
        self.children = list(children)
        self.depth = 0
        
    def show_info(self):
        print('node {0}: '.format(self.id), end = '')
        print('parent = {0}, '.format(self.parent), end = '')
        print('depth = {0}, '.format(self.depth), end = '')
        if self.children and self.parent != -1:
            print('internal node, ', end = '')
        elif self.parent != -1:
            print('leaf, ', end = '')
        else:
            print('root, ', end = '')
        print(self.children)


class RootedTree():
    def __init__(self, n):
        self.nodes = [Node(i, -1) for i in range(n)]
    
    def set_node(self, i_p):
        i_p = list(map(int, i_p.split()))
        num = i_p[0]
        children = i_p[2:]
        if children:
            self.nodes[num].children = children
            for n in children:
                self.nodes[n].parent = num

    def set_depth(self):
        for n in self.nodes:
            t_n = n
            while t_n.parent != -1:
                n.depth += 1
                t_n = self.nodes[t_n.parent]

    def show_nodes_info(self):
        for n in self.nodes:
            n.show_info()



import sys

n = int(sys.stdin.readline())

T = RootedTree(n)

for x in sys.stdin.readlines():
    T.set_node(x)

T.set_depth()

T.show_nodes_info()


# Optimized solution
class Node:
    def __init__(self, num, parent, *children):
        self.id = num
        self.parent = parent
        self.children = list(children)
        self.depth = 0
        
    def show_info(self):
        print('node {0}: '.format(self.id), end = '')
        print('parent = {0}, '.format(self.parent), end = '')
        print('depth = {0}, '.format(self.depth), end = '')
        if self.children and self.parent != -1:
            print('internal node, ', end = '')
        elif self.parent != -1:
            print('leaf, ', end = '')
        else:
            print('root, ', end = '')
        print(self.children)


def set_node(i_p):
    i_p = list(map(int, i_p.split()))
    num = i_p[0]
    children = i_p[2:]
    if children:
        T[num].children = children
        for n in children:
            T[n].parent = num

def find_root(node):
    while node.parent != -1:
        node = T[node.parent]
    return node

def set_depth(node, depth):
    node.depth = depth
    for n in node.children:
        set_depth(T[n], depth + 1)



import sys

n = int(sys.stdin.readline())

T = [Node(i, -1) for i in range(n)]

for x in sys.stdin.readlines():
    set_node(x)

r_n = find_root(T[0])

set_depth(r_n, 0)

for n in T:
    n.show_info()
# Original solution
class Node:
    def __init__(self, num, parent, children):
        self.id = num
        self.parent = -1
        self.children = children
        self.depth = 0
        
    def show_info(self):
        print('node {0}: '.format(self.id), end = '')
        print('parent = {0}, '.format(self.parent), end = '')
        print('depth = {0}, '.format(self.depth), end = '')
        if self.children and self.parent != -1:
            print('internal node, ', end = '')
        elif self.parent != -1:
            print('leaf, ', end = '')
        else:
            print('root, ', end = '')
        print(self.children)


def set_node(i_s):
    i_l = list(map(int, i_s.split()))
    num = i_l[0]
    children = i_l[2:]
    node = Node(num, -1, children)
    T[num] = node
    for n in children:
        rn_check_list.remove(n)

def set_pd(node, parent, depth):
    node.parent = parent
    node.depth = depth
    for n in node.children:
        set_pd(T[n], node.id, depth + 1)


import sys

n = int(sys.stdin.readline())

T = [None for i in range(n)]

rn_check_list = [i for i in range(n)]

for x in sys.stdin.readlines():
    set_node(x)

rn_i = rn_check_list[0]

set_pd(T[rn_i], -1, 0)

for n in T:
    n.show_info()


# Optimized solution
class Node:
    def __init__(self, num, parent, children):
        self.id = num
        self.parent = -1
        self.children = children
        self.depth = 0
        
    def show_info(self):
        print('node {0}: '.format(self.id), end = '')
        print('parent = {0}, '.format(self.parent), end = '')
        print('depth = {0}, '.format(self.depth), end = '')
        if self.children and self.parent != -1:
            print('internal node, ', end = '')
        elif self.parent != -1:
            print('leaf, ', end = '')
        else:
            print('root, ', end = '')
        print(self.children)


def set_node(i_s):
    i_l = list(map(int, i_s.split()))
    num = i_l[0]
    children = i_l[2:]
    node = Node(num, -1, children)
    T[num] = node
    for n in children:
        T[-1] -= n

def set_pd(node, parent, depth):
    node.parent = parent
    node.depth = depth
    for n in node.children:
        set_pd(T[n], node.id, depth + 1)


import sys

n = int(sys.stdin.readline())

T = [None for i in range(n)]

T.append(int(n * (n - 1) / 2))

for x in sys.stdin.readlines():
    set_node(x)

set_pd(T[T[-1]], -1, 0)

for n in T[:-1]:
    n.show_info()
# Original solution
class Node:
    def __init__(self, num, parent, children):
        self.id = num
        self.parent = -1
        self.children = children
        self.depth = 0
        
    def show_info(self):
        print('node {0}: '.format(self.id), end = '')
        print('parent = {0}, '.format(self.parent), end = '')
        print('depth = {0}, '.format(self.depth), end = '')
        if self.children and self.parent != -1:
            print('internal node, ', end = '')
        elif self.parent != -1:
            print('leaf, ', end = '')
        else:
            print('root, ', end = '')
        print(self.children)


def set_node(i_s):
    i_l = list(map(int, i_s.split()))
    num = i_l[0]
    children = i_l[2:]
    node = Node(num, -1, children)
    T[num] = node
    for n in children:
        T[-1] -= n

def set_pd(n_i, parent, depth):
    node = T[n_i]
    node.parent = parent
    node.depth = depth
    for n in node.children:
        set_pd(n, n_i, depth + 1)


import sys

n = int(sys.stdin.readline())

T = [None] * n

T.append(int(n * (n - 1) / 2))

for x in sys.stdin.readlines():
    set_node(x)

set_pd(T[-1], -1, 0)

for n in T[:-1]:
    n.show_info()


# Optimized solution
class Node:
    def __init__(self, num, parent, children):
        self.id = num
        self.parent = -1
        self.depth = 0
        self.type = None
        self.children = children
        
    def show_info(self):
        print(('node {0}: parent = {1}, depth = {2}, {3}, {4}'.format(self.id,
                                                                     self.parent,
                                                                     self.depth,
                                                                     self.type,
                                                                     self.children)))


def set_node(i_s):
    i_l = list(map(int, i_s.split()))
    num = i_l[0]
    children = i_l[2:]
    node = Node(num, -1, children)
    T[num] = node
    for n in children:
        T[-1] -= n

def set_pdt(n_i, parent, depth):
    node = T[n_i]
    node.parent = parent
    node.depth = depth
    if node.children:
        node.type = 'internal node'
        for n in node.children:
            set_pdt(n, n_i, depth + 1)
    else:
        node.type = 'leaf'


import sys

n = int(sys.stdin.readline())

T = [None] * n

T.append(int(n * (n - 1) / 2))

for x in sys.stdin.readlines():
    set_node(x)

set_pdt(T[-1], -1, 0)

T[T[-1]].type ='root'

for n in T[:-1]:
    n.show_info()
# Original solution
# -*- coding: utf-8 -*-

class Node_Class():
    def __init__(self, c_list):
        self.c_list = c_list

n = int(input())
node_dic = {}
p_list = [0]*n
d_list = [0]*n
t_list = ['']*n
for i in range(n):
    line = list(map(str, input().split()))
    if int(line[1]) > 0:
        node_dic[int(line[0])] = Node_Class(list(map(int, line[2:])))
    else:
        node_dic[int(line[0])] = Node_Class([])
#parent
for i in range(n):
    flag = False
    for j in range(n):
        if i in node_dic[j].c_list:
            p_list[i] = j
            flag = True
            break
    if not flag:
        p_list[i] = -1
#depth
for i in range(n):
    j = i
    while p_list[j] > -1:
        j = p_list[j]
        d_list[i] += 1
#type
for i in range(n):
    if p_list[i] == -1:
        t_list[i] = t_list[i] + "root"
    else:
        if len(node_dic[i].c_list):
            t_list[i] = t_list[i] + "internal node"
        else:
            t_list[i] = t_list[i] + "leaf"
#print
for i in range(n):
    s = "node %d: parent = %d, depth = %d, %s," %(i, p_list[i], d_list[i], t_list[i])
    print(s, node_dic[i].c_list)

# Optimized solution
# -*- coding: utf-8 -*-

class Node_Class():
    def __init__(self, c_list):
        self.c_list = c_list

n = int(input())
node_dic = {}
p_list = [0]*n
d_list = [0]*n
t_list = ['']*n
root = 0
for i in range(n):
    root += i
for i in range(n):
    line = list(map(str, input().split()))
    if int(line[1]) > 0:
        node_dic[int(line[0])] = Node_Class(list(map(int, line[2:])))
    else:
        node_dic[int(line[0])] = Node_Class([])
#parent
for i in range(n):
    for j in node_dic[i].c_list:
        p_list[j] = i
        root -= j
p_list[root] = -1
#depth
for i in range(n):
    j = i
    while p_list[j] > -1:
        j = p_list[j]
        d_list[i] += 1
#type
for i in range(n):
    if p_list[i] == -1:
        t_list[i] = t_list[i] + "root"
    else:
        if len(node_dic[i].c_list):
            t_list[i] = t_list[i] + "internal node"
        else:
            t_list[i] = t_list[i] + "leaf"
#print
for i in range(n):
    s = "node %d: parent = %d, depth = %d, %s," %(i, p_list[i], d_list[i], t_list[i])
    print(s, node_dic[i].c_list)
# Original solution
def q(a,h):
 d[a]=str(h)
 for b in t[a]:q(b,h+1)
t,p,d={},{},{}
for _ in[0]*int(eval(input())):
 e=input().split()
 t[e[0]]=e[2:]
 for i in e[2:]:p[i]=e[0]
r=(set(t)-set(p)).pop()
p[r]='-1'
q(r,0)
for i in sorted(map(int,t)):
 i=str(i)
 f='root'if'-1'==p[i]else'internal node'if t[i]else'leaf'
 print(f'node {i}: parent = {p[i]}, depth = {d[i]}, {f}, {list(map(int,t[i]))}')


# Optimized solution
def q(a,h):
 d[a]=str(h)
 for b in t[a]:q(b,h+1)
t,p,d={},{},{}
for _ in[0]*int(eval(input())):
 e=input().split()
 t[e[0]]=e[2:]
 for i in e[2:]:p[i]=e[0]
r=(set(t)-set(p)).pop()
p[r]='-1'
q(r,0)
for i in sorted(map(int,t)):i=str(i);print(f"node {i}: parent = {p[i]}, depth = {d[i]}, {'root'if'-1'==p[i]else'internal node'if t[i]else'leaf'}, [{', '.join(t[i])}]")
# Original solution
def q(a,h):
 d[a]=str(h)
 for b in t[a]:q(b,h+1)
t,p,d={},{},{}
for _ in[0]*int(eval(input())):
 e=input().split()
 t[e[0]]=e[2:]
 for i in e[2:]:p[i]=e[0]
r=(set(t)-set(p)).pop()
p[r]='-1'
q(r,0)
print(('\n'.join(f"node {i}: parent = {p[i]}, depth = {d[i]}, {'root'if'-1'==p[i]else'internal node'if t[i]else'leaf'}, [{', '.join(t[i])}]"for i in map(str,sorted(map(int,t))))))


# Optimized solution
import sys
def q(a,h):
 d[a]=str(h)
 for b in t[a]:q(b,h+1)
t,p,d={},{},{}
eval(input())
for e in sys.stdin:
 e=e.split()
 t[e[0]]=e[2:]
 for i in e[2:]:p[i]=e[0]
r=(set(t)-set(p)).pop()
p[r]='-1'
q(r,0)
print(('\n'.join(f"node {i}: parent = {p[i]}, depth = {d[i]}, {'root'if'-1'==p[i]else'internal node'if t[i]else'leaf'}, [{', '.join(t[i])}]"for i in map(str,sorted(map(int,t))))))