loj#P3476. 「ROIR 2021 Day 1」绳子

「ROIR 2021 Day 1」绳子

Description

Translated from Chinese version of ROIR 2021 Day1 T4 Антенна on this website.

There are nn ropes, among which the ii-th rope is sis_i centimeter long. Besides, mim_i nodes are on that rope, and the jj-th node is pi, jp_{i,~j} centimeter away from the leftmost side of the rope.

Your task is to find a solution to connect ropes from left to right satisfying that all distances between adjacent nodes equals after connecting qiq_i-th and qi+1q_{i+1}-th ropes, whereas qq represents the solution and would obviously be a permutation of 1n1\sim n.

Output No if such solution does not exist.

Input Format

The first line will be an integer nn.

In the following 2n2n lines:

  • The (2i)(2i)-th line would be two integers, mim_i and sis_i
  • The (2i+1)(2i+1)-th line would be mim_i integers, respectively pi,jp_{i,j}

Note that the value of ii above satisfies 1in1\le i\le n.

Output Format

If the solution could be found, output Yes in the first line and nn integers qiq_i in the following line.

Otherwise, output No.

3
1 7
3
1 8
6
2 8
1 6
Yes
2 1 3
1
1 7
5
Yes
1
1
3 10
2 5 9
No
3
1 5
3
1 3
3
1 6
3
No
4
1 5
0
1 0
0
1 3
3
1 0
0
Yes
3 2 4 1

Constraints

It is guaranteed that for all subtasks, there are 1n1051\le n\le 10^5, 1mi1051\le m_i\le 10^5, 0si1090\le s_i\le 10^9, 0pi,1<pi,2<<pi,misi0\le p_{i,1}<p_{i,2}<\cdots<p_{i,m_i}\le s_i, mi105\sum m_i\le 10^5.

Subtask # Additional Constraints Score
11 n8n\le 8mi=1m_i=1si100s_i\le 100 88
22 n8n\le 8si100s_i\le 100
33 n103n\le 10^3 2121
44 mi>n\sum m_i>n
55 si100s_i\le 100
66 No additional constraints