Find one story vector satisfying n linear equations, then the minimum number of starting people whose reach covers all n people.
Hard9MathGraphDFSNo attempts yetTime limit2sMemory limit512 MBA social network has n people, numbered 1 to n. One news story is described by d real numbers c1,c2,…,cd, where cj says how hard the story pushes topic j. These numbers do not have to be integers.
Person i comes with an interest vector ai1,ai2,…,aid and a threshold ti. Person i likes a story exactly when ai1c1+ai2c2+⋯+aidcd=ti. A sum above the threshold is no better than a sum below it, so only an exact match works.
Someone who receives the story and likes it passes it on to everyone on their share list. Someone who does not like it passes it to nobody. You pick the people who receive the story first, and you may pick several, but every one of them gets the same single story.
Design one story that all n people like. Such a story does not always exist, and you report that when it happens. When it does exist, report the smallest number of people you have to start the story at so that every person receives it.
The first line holds the number of data sets K. After it come K data sets.
The first line of a data set holds the number of people n and the number of topics d. Each of the next n lines describes one person: line i holds the integers ai1,…,aid, then the threshold ti, then the size ki of the share list, then the ki numbers of the people person i sends news to.
1≤K≤20, 1≤n≤100, 1≤d≤20, ∣aij∣≤100, ∣ti∣≤1000, and 0≤ki≤n−1. The numbers on a share list are distinct and never include i.
For each data set, print Data Set x: on a line by itself, where x is the number of the data set counting from 1. On the next line print the smallest number of people you have to start the story at so that everyone receives it, or Impossible when no story satisfies all n people. Print a blank line after each data set.