During the summer holidays, Derek likes to play his favourite video game, League of Legends. Derek plays days in a row, not because he's hopelessly addicted, but because he wants to climb the ranked ladder. On each day, he wins matches and loses matches. He starts with 0 points and winning a match rewards him with points, while losing a game costs Derek points. At the end of the days, a corrupt admin provides Derek the chance to delete the losses between days and (inclusive). For each of the queries in the form , output the total amount of points Derek will have after the selected losses are deleted.
Input Specification
The first line of input contains one integer, , the number of days he played.
The next lines contain two integers and , representing the wins and losses.
The next line contains one integer, , the number of queries to follow.
The next lines contain two integers and , representing each of the queries.
Output Specification
For each query, output one integer , the total amount of points Derek has after the days.
Contraints
Sample Input
3
1 2
3 1
2 2
1
2 3
Sample Output
100
Comments