Time limit: 1.5 seconds Memory limit: 256 MB After Leete's failed attempts to make Fite…
- User
Time limit: 1.5 seconds Memory limit: 256 MB After Leete's failed attempts to make Fite happy, she decides to enroll herself and Fite in the next program of the university mountain group, so that the multi-day trip will improve their relationship.
The next program of the mountain group will be held in the Baqmachgah area, whose resorts and communication routes between them are like a directed graph. In this graph:
There is at most one direct way from one resort to another. (There may be two different ways between the two resorts in opposite directions) There is no direct way from a resort to itself. It may exist in the distance graph. But exactly one day before leaving for Baqmachgah, Leyte receives unpleasant news that during the days of the program, we will witness earthquakes and aftershocks in this resort area.
More specifically, it will be that for each resort, on some days there will be a vibration event at that resort. The first tremor at a fault is an earthquake, and all subsequent tremors are aftershocks. (The difference between earthquake and aftershock is explained below) Unfortunately, if an earthquake happens in one of the resorts in this area, all the people living in this resort will rush to their homeland. And if there is an aftershock in a resort, the residents should flee to one of the resorts that have a direct exit. This escape takes exactly one day. Note that if there is an aftershock in a resort and that resort does not have a direct exit to another resort, they will have to give up their lives.
The important point is that Lite and Fite will be together in this trip and whenever they have to escape, they will choose one of the possible resorts together and go there. That is, they will remain in place until an earthquake occurs.
In the middle of the night, by connecting with Mehrsa's soul, Lite learns about the time of all earthquakes and aftershocks, and now questions keep coming to her mind that if during the day t t-th camp at resort no x x, is it possible to survive until the end of the camp or not. Naturally, you should help him in solving this problem.
input The first line of input contains three natural numbers n n and m m and q q are the number of rest stops, the number of one-way paths between them, and the number of questions of the Liete mind, respectively. 1 ≤ n , m , q ≤ 400
000 1≤n,m,q≤400 000 in i The i-th line of n n the next line of information about the vibrations of the resort no i i comes, so that at the beginning the number k k stands for the number of city vibrations i i is followed by k k number like t t are in ascending order, indicating the days in the city i i Vibration has occurred.
The first tremor of any city is an earthquake, and the rest of the tremors in that city are aftershocks. All vibrations are guaranteed to have different timings. That is, vibration does not happen in two resting places at the same time. 0 ≤ k ≤ 400
000 0≤k≤400 000 1 ≤ t ≤ 1 0 9 1≤t≤10 9
It is also guaranteed that the total number of vibrations is less equal 400
- Assistant