ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules

NEERC 2014, Eastern subregional contest

About     Problems     Submit solution     Judge status     Standings
Contest is over

B. Neither shaken nor stirred

Time limit: 1.0 second
Memory limit: 64 MB
The ACM ICPC regional contest in St. Petersburg is a stressful event even for veterans of competetive programming. That’s why for the last four years programmer Denchik and his coach Vova go to their favorite bars to relax after the event. Having entered a bar, Denchik immediately orders cocktail “B-52”. If there is no such cocktail on the menu he drinks nothing. On the other hand, in places, where the cocktail is good, Denchik can repeat his order several times.
Vova, as an elder friend, tries to control his trainee drunkenness degree. When entering and leaving bars, Vova asks Denchik how many cocktails he has drunk in the last bar where B-52 was served. If Denchik is not sure about the answer, Vova considers Denchik’s drinking enough for this day and takes him to the hotel.
This year the story repeats again. Denchik has the experience of four previous regional contests and knows which bars serve B-52 and how many cocktails he’s going to drink in each bar at one visit. He also knows where they can go after leaving every bar on their route. For which bars Denchik may prepare right answers to Vova’s questions in advance, no matter what route they choose?

Input

The first line contains an integer n which is the number of bars (1 ≤ n ≤ 100 000). Next n lines describe these bars. The i-th line contains integers ki, mi, ni1, ni2, …, nimi (0 ≤ ki ≤ 100 000; 0 ≤ min). If ki equals zero, then in bar i B-52 is not served, and if ki is positive, it means that Denchik will drink ki cocktails at one visit to bar i. ni1, ni2, …, nimi are the numbers of the bars friends can go to right after leaving bar i (1 ≤ nijn; nij < ni,j+1). There can be number i among the numbers nij, and it means that after leaving bar i friends can hang around and enter the same bar again. The sum of all numbers mi does not exceed 100 000.
The bars are numbered in the order they are in the input data. Bar with number 1 is the bar from which Vova and Denchik begin their journey. It is guaranteed that during the night friends can reach every bar listed in the input.

Output

In the i-th of n lines output Denchik’s answers to Vova’s question on entering bar i and leaving it. Every answer should have one of the following forms:
  • sober, if Denchik hasn’t drunk any B-52 yet
  • X, if during the last visit to the bar where B-52 was served Denchik drunk X cocktails (X is an integer from 1 to 100 000)
  • unknown, if with different routes to the i-th bar different situations are possible

Samples

inputoutput
5
0 2 2 3
6 1 4
5 2 4 5
5 1 5
0 0
sober sober
sober 6
sober 5
unknown 5
5 5
2
0 2 1 2
0 2 1 2
sober sober
sober sober
Problem Author: Alex Samsonov (prepared by Egor Shchelkonogov)
Problem Source: NEERC 2014, Eastern subregional contest
To submit the solution for this problem go to the Problem set: 2013. Neither shaken nor stirred