Clarke is a patient with multiple personality disorder. One day, Clarke turned into a game player of minecraft. On that day, Clarke set up local network and chose create mode for sharing his achievements with others. Unfortunately, a naughty kid came his game. He placed a few creepers in Clarke's castle! When Clarke returned his castle without create mode, creepers suddenly blew(what a amazing scene!). Then Clarke's castle in ruins, the materials scattered over the ground. Clark had no choice but to pick up these ruins, ready to rebuild. After Clarke built some chests(boxes), He had to pick up the material and stored them in the chests. Clarke clearly remembered the type and number of each item(each item was made of only one type material) . Now Clarke want to know how many times he have to transport at least. Note: Materials which has same type can be stacked, a grid can store 64 materials of same type at most. Different types of materials can be transported together. Clarke's bag has 4*9=36 grids.
The first line contains a number $T(1 \le T \le 10)$, the number of test cases. For each test case: The first line contains a number $n$, the number of items. Then $n$ lines follow, each line contains two integer $a, b(1 \le a, b \le 500)$, $a$ denotes the type of material of this item, $b$ denotes the number of this material.
For each testcase, print a number, the number of times that Clarke need to transport at least.