In Apollo's country, basketball is the most popular sport. There are n basketball players and m basketball fans. Bastketball players are numbered from 1 to n. Basketball fans are numbered from 1 to m.
A basketball fan can be a fan of multiple players.
Basketball fan i is like to watch the game of player j if one of the following conditions is met:
- Basketball fan i is a fan of basketball player j.
- There is a fan i' and a player j', both fan i and fan i' are like to watch the game of player j', and fan i' is like to watch the game of player j.
The All-Star Game is an annual exhibition basketball game. You need to select some players into the All-Star Game. A fan will watch the All-Star Game if he is like to watch the game of one selected player (i.e. at least one of the players that the fan is like to watch was selected). You need to decide the minimum number of players need to be selected into All-Star Game so that all basketball fans will watch the game.
Initially, some basketball players will have some fans. There are q changes to the relationship between basketball players and basketball fans.
After each of q changes, print one integer --- the minimum number of players which you have to select to make all basketball fans will watch the game. Print "-1" if it is impossible.
输入描述:
The first line contains three integers n, m and q (
) - the number of basketball players, the number of basketball fans and the number of changes respectively.
Then n lines follow. The i-th line starts with one integer
(
) - the initial number of fans of basketball player i, then contains
different integers - present the fans of player i.
.
Then q lines follow. The i-th line contains two integers x and y (
,
). If fan x is a fan of basketball player y, then fan x will be not a fan of player y, otherwise, fan x will be a fan of player y.
输出描述:
After each change print one integer --- the minimum number of players need to be selected into All-Star Game so that all basketball fans will watch the game. Pritn "-1" if it is impossible.
示例1
输入
复制
4 4 6
2 1 2
0
2 2 3
1 4
4 2
2 3
2 1
2 2
4 2
4 1