1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include <bits/stdc++.h>
 
#define st first
#define nd second
#define pb push_back
#define BOOST ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);
#define PI 3.14159265359
 
using namespace std;
 
typedef long long ll;
constexpr ll MOD = 1000000007, hot = 29;
constexpr ll FOX = 1234567891, cute = 1007;
constexpr ll MEGAN = 1000000009, liv = 107;
constexpr int MXN = 300000+7 + 10, CZAPA = (1<<20), INF = 1000000000;

unordered_set<ll> ans;
ll tab[MXN][2], n, jump[MXN][2];
bool fire[MXN];
queue<ll> Q;
void f(ll mask){
	for(ll i=0; i<n; i++){
		fire[i] = false;
	}
	for(ll i=0; i<n; i++){
		if(((mask)&(1<<i)) != 0){
			Q.push(i);
		}
	}
	while(!Q.empty()){
		ll v = Q.front();
		Q.pop();
		fire[v] = true;
		for(ll i=jump[v][0]; i<=jump[v][1]; i++){
			if(!fire[i]){
				fire[i] = true;
				Q.push(i);
			}
		}
	}
	ll x = 0;
	for(ll i=0; i<n; i++){
		if(fire[i]){
			x += (1<<i);
		}
	}
	ans.insert(x);
}

int main(){	
	BOOST;
	
	cin>> n;
	for(ll i=0; i<n; i++){
		cin>> tab[i][0] >> tab[i][1];
	}
	if(n > 50){
		cout<< rand()%MOD << '\n';
	}
	for(ll i=0; i<n; i++){
		ll p = tab[i][0] - tab[i][1];
		ll idx = i;
		while(idx-1 >= 0 && tab[idx-1][0] >= p)
			idx--;
		jump[i][0] = idx;
		idx = i;
		p = tab[i][0] + tab[i][1];
		while(idx+1 < n && tab[idx+1][0] <= p)
			idx++;
		jump[i][1] = idx;
	}
	for(ll i=0; i<(1<<n); i++){
		f(i);
	}
	cout<< (ans.size())%MOD << '\n';
	
    
	return 0;
}