Candy
문제
It is Saturday and Ann Britt-Caroline is going to buy candy. She has identified several different bags of candy she is considering buying.
Each bag contains a number of pieces of candy of different types. There are 10 types of normal candy (these are numbered ), and 10 types of anti-candy (numbered ). It just so happens that candy of type and type do not go well together - they are annihilated if they come in contact with each other. Other than that anti-candy tastes just the same as normal candy.
When Ann Britt-Caroline has bought the bags of candy she mixes them in a big bowl such that all pairs of candy/anti-candy is annihilated (she mixes thoroughly). How many pieces of candy can Ann Britt-Caroline have left (after all pairs of candy/ant-candy is annihilated), if she selects her bags of candy optimally? Note that she can only buy one bag of each type. Ignore any money related issues - her parents will pay.
입력
The first line in the input consist of an integer - the number of bags of candy.
The following lines describe each bag of candy. Each line starts with an integer , specifying the number of different types of candy in the bag. Then follow pairs of integers , which means that there are pieces of candy type . Each type of candy is mentioned at most once per bag, and types and can not be in the same bag.
For all , .
출력
Print an integer: the largest amount of candy Ann Britt-Caroline can have in the end.
예제
예제 1
3 1 1 3 2 -1 1 -2 5 2 2 2 -3 1
7