p01052 Movie
Problem

Taro decided to watch one movie every day at a nearby movie theater during the summer vacation. (Taro has 31 days of summer vacation from August 1st to August 31st.)

The theater is set to show n movies during the summer vacation. Each movie is assigned a number from 1 to n, and the i-th movie will only be shown between August ai and August bi.

When Taro sees a movie, he gets 100 happiness if it's the first movie he sees. But if you've seen a movie even once in the past, you'll get 50 happiness.

Taro decided to make a plan for the summer vacation based on the schedule of the movie to be screened. Find the total value when watching the movie so that the total value of happiness that Taro can get is maximized.

It is guaranteed that one or more movies will be shown each day.

Constraints

* 1 ≤ n ≤ 100
* 1 ≤ ai ≤ bi ≤ 31 (1 ≤ i ≤ n)

Input

The input is given in the following format.


n
a1 b1
a2 b2
...
an bn


The first line is given one integer n. Of the n lines from the second line, the i line is given two integers ai and bi, separated by blanks.

Output

Output the maximum value of the total happiness that Taro can obtain.

Examples

Input

4
1 31
2 2
2 3
3 3


Output

1700


Input

5
1 10
10 20
20 21
22 31
4 20


Output

1800
```python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

N = int(input())
As = []
Bs = []
movies = [[] for x in range(31)]
for n in range(N):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    As.append(a)
    Bs.append(b)
    for day in range(a, b+1):
        movies[day].append(n)

picked = [False] * N
ans = 0
for day in range(31):
    # ????????????????????????
    unseen_movies = [m for m in movies[day] if not picked[m]]

    # ???????????????????????????
    if len(unseen_movies) == 0:
        ans += 50
    else:
        # ????????????????????????????????????????????£??¨????????????????????????????????????
        lastday = 1000
        should_see = -1
        for m in unseen_movies:
            if Bs[m] < lastday:
                lastday = Bs[m]
                should_see = m
        picked[should_see] = True
        ans += 100
print(ans)
```