#pragma comment(linker, "/STACK:16777216")
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <iterator>

using namespace std;

int main()
{
	int n;
	scanf("%d", &n);
	set<int> l, r;
	set<int> v;
	vector<int> now;
	int ans = 0;
	long long all = 1;
	for (int i = 0; i < n; i++)
	{
		char a[10];
		int p;
		scanf("%s %d", a, &p);
		if (v.find(p) == v.end())
		{
			v.insert(p);
			now.push_back(p);
		}
		else
		{
			if (l.find(-p) != l.end())
			{
				if ((*l.begin() != -p))
				{
					cout << 0;
					return 0;
				}
				l.erase(-p);
				all *= 2;
				all %= 1000000007;
				for (int j = 0; j < now.size(); j++)
				{
					if (now[j] < p)
						l.insert(-now[j]);
					else
						r.insert(now[j]);
				}
				now.clear();
				continue;
			}
			if (r.find(p) != r.end())
			{
				if ((*r.begin() != p))
				{
					cout << 0;
					return 0;
				}
				r.erase(p);
				all *= 2;
				all %= 1000000007;
				for (int j = 0; j < now.size(); j++)
				{
					if (now[j] < p)
						l.insert(-now[j]);
					else
						r.insert(now[j]);
				}
				now.clear();
				continue;
			}
			all *= 2;
			all %= 1000000007;
			for (int j = 0; j < now.size(); j++)
			{
				if (now[j] == p)
					continue;
				if (now[j] < p)
					l.insert(-now[j]);
				else
					r.insert(now[j]);
			}
			now.clear();
		}
	}
	if (l.size() == 0 && r.size() == 0)
	{
		all *= (now.size() + 1);
		all %= 1000000007;
	}
	else
	{
		int maxi = -1e9, mini = 1e9;
		if (l.size() != 0)
			maxi = -*l.begin();
		if (r.size() != 0)
			mini = *r.begin();
		int cnt = 0;
		for (int i = 0; i < now.size(); i++)
		{
			if (now[i] > maxi && now[i] < mini)
			{
				cnt++;
			}
		}
		all *= (cnt + 1);
		all %= 1000000007;
	}
	cout << all;
	return 0;
}


#pragma comment(linker, "/STACK:16777216")
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <iterator>

using namespace std;

int main()
{
	int n;
	scanf("%d", &n);
	set<int> l, r;
	set<int> v;
	vector<int> now;
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		char a[10];
		int p;
		scanf("%s %d", a, &p);
		if (v.find(p) == v.end())
		{
			v.insert(p);
			now.push_back(p);
		}
		else
		{
			if (l.find(-p) != l.end())
			{
				if ((*l.begin() != -p))
				{
					cout << 0;
					return 0;
				}
				l.erase(-p);
				ans++;
				for (int j = 0; j < now.size(); j++)
				{
					if (now[j] < p)
						l.insert(-p);
					else
						r.insert(p);
				}
				continue;
			}
			if (r.find(p) != r.end())
			{
				if ((*r.begin() != p))
				{
					cout << 0;
					return 0;
				}
				r.erase(p);
				ans++;
				for (int j = 0; j < now.size(); j++)
				{
					if (now[j] < p)
						l.insert(-now[j]);
					else
						r.insert(now[j]);
				}
				continue;
			}
			ans++;
			for (int j = 0; j < now.size(); j++)
			{
				if (now[j] == p)
					continue;
				if (now[j] < p)
					l.insert(-now[j]);
				else
					r.insert(now[j]);
			}
		}
	}
	int cnt = 1;
	for (int i = 0; i < ans; i++)
	{
		cnt *= 2;
		cnt %= 1000000007;
	}
	cout << cnt;
	return 0;
}


#pragma comment(linker, "/STACK:16777216")
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <iterator>

using namespace std;

int main()
{
	int n;
	scanf("%d", &n);
	set<int> l, r;
	set<int> v;
	vector<int> now;
	int ans = 0;
	long long all = 1;
	for (int i = 0; i < n; i++)
	{
		char a[10];
		int p;
		scanf("%s %d", a, &p);
		if (v.find(p) == v.end())
		{
			v.insert(p);
			now.push_back(p);
		}
		else
		{
			if (l.find(-p) != l.end())
			{
				if ((*l.begin() != -p))
				{
					cout << 0;
					return 0;
				}
				l.erase(-p);
				if (l.size() == 0 && r.size() == 0)
				{
					all *= (now.size() + 1);
					all %= 1000000007;
				}
				for (int j = 0; j < now.size(); j++)
				{
					if (now[j] < p)
						l.insert(-p);
					else
						r.insert(p);
				}
				now.clear();
				continue;
			}
			if (r.find(p) != r.end())
			{
				if ((*r.begin() != p))
				{
					cout << 0;
					return 0;
				}
				r.erase(p);
				if (l.size() == 0 && r.size() == 0)
				{
					all *= (now.size() + 1);
					all %= 1000000007;
				}
				for (int j = 0; j < now.size(); j++)
				{
					if (now[j] < p)
						l.insert(-now[j]);
					else
						r.insert(now[j]);
				}
				now.clear();
				continue;
			}
			if (l.size() == 0 && r.size() == 0)
			{
				all *= (now.size() + 1);
				all %= 1000000007;
			}
			for (int j = 0; j < now.size(); j++)
			{
				if (now[j] == p)
					continue;
				if (now[j] < p)
					l.insert(-now[j]);
				else
					r.insert(now[j]);
			}
			now.clear();
		}
	}
	all *= (now.size() + 1);
	all %= 1000000007;
	cout << all;
	return 0;
}


#pragma comment(linker, "/STACK:16777216")
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <iterator>

using namespace std;

int main()
{
	int n;
	scanf("%d", &n);
	set<int> l, r;
	set<int> v;
	vector<int> now;
	int ans = 0;
	long long all = 1;
	for (int i = 0; i < n; i++)
	{
		char a[10];
		int p;
		scanf("%s %d", a, &p);
		if (v.find(p) == v.end())
		{
			v.insert(p);
			now.push_back(p);
		}
		else
		{
			if (l.find(-p) != l.end())
			{
				if ((*l.begin() != -p))
				{
					cout << 0;
					return 0;
				}
				l.erase(-p);
				all *= 2;
				all %= 1000000007;
				for (int j = 0; j < now.size(); j++)
				{
					if (now[j] < p)
						l.insert(-p);
					else
						r.insert(p);
				}
				all *= (now.size() + 1);
				all %= 1000000007;
				now.clear();
				continue;
			}
			if (r.find(p) != r.end())
			{
				if ((*r.begin() != p))
				{
					cout << 0;
					return 0;
				}
				r.erase(p);
				all *= 2;
				all %= 1000000007;
				for (int j = 0; j < now.size(); j++)
				{
					if (now[j] < p)
						l.insert(-now[j]);
					else
						r.insert(now[j]);
				}
				all *= (now.size() + 1);
				all %= 1000000007;
				now.clear();
				continue;
			}
			all *= 2;
			all %= 1000000007;
			for (int j = 0; j < now.size(); j++)
			{
				if (now[j] == p)
					continue;
				if (now[j] < p)
					l.insert(-now[j]);
				else
					r.insert(now[j]);
			}
			all *= (now.size() + 1);
			all %= 1000000007;
			now.clear();
		}
	}
	all *= (now.size() + 1);
	all %= 1000000007;
	cout << all;
	return 0;
}


#pragma comment(linker, "/STACK:16777216")
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <iterator>

using namespace std;

int main()
{
	int n;
	scanf("%d", &n);
	set<int> l, r;
	set<int> v;
	vector<int> now;
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		char a[10];
		int p;
		scanf("%s %d", a, &p);
		if (v.find(p) == v.end())
		{
			v.insert(p);
			now.push_back(p);
		}
		else
		{
			if (l.find(-p) != l.end())
			{
				if ((*l.begin() != -p))
				{
					cout << 0;
					return 0;
				}
				l.erase(-p);
				ans++;
				for (int j = 0; j < now.size(); j++)
				{
					if (now[j] < p)
						l.insert(-p);
					else
						r.insert(p);
				}
				now.clear();
				continue;
			}
			if (r.find(p) != r.end())
			{
				if ((*r.begin() != p))
				{
					cout << 0;
					return 0;
				}
				r.erase(p);
				ans++;
				for (int j = 0; j < now.size(); j++)
				{
					if (now[j] < p)
						l.insert(-now[j]);
					else
						r.insert(now[j]);
				}
				now.clear();
				continue;
			}
			ans++;
			for (int j = 0; j < now.size(); j++)
			{
				if (now[j] == p)
					continue;
				if (now[j] < p)
					l.insert(-now[j]);
				else
					r.insert(now[j]);
			}
			now.clear();
		}
	}
	ans += now.size();
	int cnt = 1;
	for (int i = 0; i < ans; i++)
	{
		cnt *= 2;
		cnt %= 1000000007;
	}
	cout << cnt;
	return 0;
}


#pragma comment(linker, "/STACK:16777216")
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <iterator>

using namespace std;

int main()
{
	int n;
	scanf("%d", &n);
	set<int> l, r;
	set<int> v;
	vector<int> now;
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		char a[10];
		int p;
		scanf("%s %d", a, &p);
		if (v.find(p) == v.end())
		{
			v.insert(p);
			now.push_back(p);
		}
		else
		{
			if (l.find(-p) != l.end())
			{
				if ((*l.begin() != -p))
				{
					cout << 0;
					return 0;
				}
				l.erase(-p);
				ans++;
				for (int j = 0; j < now.size(); j++)
				{
					if (now[j] < p)
						l.insert(-p);
					else
						r.insert(p);
				}
				now.clear();
				continue;
			}
			if (r.find(p) != r.end())
			{
				if ((*r.begin() != p))
				{
					cout << 0;
					return 0;
				}
				r.erase(p);
				ans++;
				for (int j = 0; j < now.size(); j++)
				{
					if (now[j] < p)
						l.insert(-now[j]);
					else
						r.insert(now[j]);
				}
				now.clear();
				continue;
			}
			ans++;
			for (int j = 0; j < now.size(); j++)
			{
				if (now[j] == p)
					continue;
				if (now[j] < p)
					l.insert(-now[j]);
				else
					r.insert(now[j]);
			}
			now.clear();
		}
	}
	if (ans == 0)
		ans = n;
	int cnt = 1;
	for (int i = 0; i < ans; i++)
	{
		cnt *= 2;
		cnt %= 1000000007;
	}
	cout << cnt;
	return 0;
}


#pragma comment(linker, "/STACK:16777216")
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <iterator>

using namespace std;

int main()
{
	int n;
	scanf("%d", &n);
	set<int> l, r;
	set<int> v;
	vector<int> now;
	int ans = 0;
	long long all = 1;
	for (int i = 0; i < n; i++)
	{
		char a[10];
		int p;
		scanf("%s %d", a, &p);
		if (v.find(p) == v.end())
		{
			v.insert(p);
			now.push_back(p);
		}
		else
		{
			if (l.find(-p) != l.end())
			{
				if ((*l.begin() != -p))
				{
					cout << 0;
					return 0;
				}
				l.erase(-p);
				all *= 2;
				all %= 1000000007;
				for (int j = 0; j < now.size(); j++)
				{
					if (now[j] < p)
						l.insert(-p);
					else
						r.insert(p);
				}
				all *= (now.size + 1);
				all %= 1000000007;
				now.clear();
				continue;
			}
			if (r.find(p) != r.end())
			{
				if ((*r.begin() != p))
				{
					cout << 0;
					return 0;
				}
				r.erase(p);
				all *= 2;
				all %= 1000000007;
				for (int j = 0; j < now.size(); j++)
				{
					if (now[j] < p)
						l.insert(-now[j]);
					else
						r.insert(now[j]);
				}
				all *= (now.size() + 1);
				all %= 1000000007;
				now.clear();
				continue;
			}
			all *= 2;
			all %= 1000000007;
			for (int j = 0; j < now.size(); j++)
			{
				if (now[j] == p)
					continue;
				if (now[j] < p)
					l.insert(-now[j]);
				else
					r.insert(now[j]);
			}
			all *= (now.size() + 1);
			all %= 1000000007;
			now.clear();
		}
	}
	all *= (now.size() + 1);
	all %= 1000000007;
	cout << all;
	return 0;
}


#pragma comment(linker, "/STACK:16777216")
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <iterator>

using namespace std;

int main()
{
	int n;
	scanf("%d", &n);
	set<int> l, r;
	set<int> v;
	vector<int> now;
	int ans = 0;
	long long all = 1;
	for (int i = 0; i < n; i++)
	{
		char a[10];
		int p;
		scanf("%s %d", a, &p);
		if (v.find(p) == v.end())
		{
			v.insert(p);
			now.push_back(p);
		}
		else
		{
			if (l.find(-p) != l.end())
			{
				if ((*l.begin() != -p))
				{
					cout << 0;
					return 0;
				}
				l.erase(-p);
				for (int j = 0; j < now.size(); j++)
				{
					if (now[j] < p)
						l.insert(-now[j]);
					else
						r.insert(now[j]);
				}
				now.clear();
				continue;
			}
			if (r.find(p) != r.end())
			{
				if ((*r.begin() != p))
				{
					cout << 0;
					return 0;
				}
				r.erase(p);
				for (int j = 0; j < now.size(); j++)
				{
					if (now[j] < p)
						l.insert(-now[j]);
					else
						r.insert(now[j]);
				}
				now.clear();
				continue;
			}
			all *= 2;
			all %= 1000000007;
			for (int j = 0; j < now.size(); j++)
			{
				if (now[j] == p)
					continue;
				if (now[j] < p)
					l.insert(-now[j]);
				else
					r.insert(now[j]);
			}
			now.clear();
		}
	}
	if (l.size() == 0 && r.size() == 0)
	{
		all *= (now.size() + 1);
		all %= 1000000007;
	}
	else
	{
		int maxi = -1e9, mini = 1e9;
		if (l.size() != 0)
			maxi = -*l.begin();
		if (r.size() != 0)
			mini = *r.begin();
		int cnt = 0;
		for (int i = 0; i < now.size(); i++)
		{
			if (now[i] > maxi && now[i] < mini)
			{
				cnt++;
			}
		}
		all *= (cnt + 1);
		all %= 1000000007;
	}
	cout << all;
	return 0;
}


#pragma comment(linker, "/STACK:16777216")
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <iterator>

using namespace std;

int main()
{
	int n;
	scanf("%d", &n);
	set<int> l, r;
	set<int> v;
	vector<int> now;
	int ans = 0;
	long long all = 1;
	for (int i = 0; i < n; i++)
	{
		char a[10];
		int p;
		scanf("%s %d", a, &p);
		if (v.find(p) == v.end())
		{
			v.insert(p);
			now.push_back(p);
		}
		else
		{
			if (l.find(-p) != l.end())
			{
				if ((*l.begin() != -p))
				{
					cout << 0;
					return 0;
				}
				l.erase(-p);
				all *= 2;
				all %= 1000000007;
				for (int j = 0; j < now.size(); j++)
				{
					if (now[j] < p)
						l.insert(-p);
					else
						r.insert(p);
				}
				now.clear();
				continue;
			}
			if (r.find(p) != r.end())
			{
				if ((*r.begin() != p))
				{
					cout << 0;
					return 0;
				}
				r.erase(p);
				all *= 2;
				all %= 1000000007;
				for (int j = 0; j < now.size(); j++)
				{
					if (now[j] < p)
						l.insert(-now[j]);
					else
						r.insert(now[j]);
				}
				now.clear();
				continue;
			}
			all *= 2;
			all %= 1000000007;
			for (int j = 0; j < now.size(); j++)
			{
				if (now[j] == p)
					continue;
				if (now[j] < p)
					l.insert(-now[j]);
				else
					r.insert(now[j]);
			}
			now.clear();
		}
	}
	all *= (now.size() + 1);
	all %= 1000000007;
	cout << all;
	return 0;
}


#pragma comment(linker, "/STACK:16777216")
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <iterator>

using namespace std;

int main()
{
	int n;
	scanf("%d", &n);
	set<int> l, r;
	set<int> v;
	vector<int> now;
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		char a[10];
		int p;
		scanf("%s %d", a, &p);
		if (v.find(p) == v.end())
		{
			v.insert(p);
			now.push_back(p);
		}
		else
		{
			if (l.find(-p) != l.end())
			{
				if ((*l.begin() != -p))
				{
					cout << 0;
					return 0;
				}
				l.erase(-p);
				ans++;
				for (int j = 0; j < now.size(); j++)
				{
					if (now[j] < p)
						l.insert(-p);
					else
						r.insert(p);
				}
				now.clear();
				continue;
			}
			if (r.find(p) != r.end())
			{
				if ((*r.begin() != p))
				{
					cout << 0;
					return 0;
				}
				r.erase(p);
				ans++;
				for (int j = 0; j < now.size(); j++)
				{
					if (now[j] < p)
						l.insert(-now[j]);
					else
						r.insert(now[j]);
				}
				now.clear();
				continue;
			}
			ans++;
			for (int j = 0; j < now.size(); j++)
			{
				if (now[j] == p)
					continue;
				if (now[j] < p)
					l.insert(-now[j]);
				else
					r.insert(now[j]);
			}
			now.clear();
		}
	}
	int cnt = 1;
	for (int i = 0; i < ans; i++)
	{
		cnt *= 2;
		cnt %= 1000000007;
	}
	cout << cnt;
	return 0;
}


#pragma comment(linker, "/STACK:16777216")
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <iterator>

using namespace std;

int main()
{
	int n;
	scanf("%d", &n);
	set<int> l, r;
	set<int> v;
	vector<int> now;
	int ans = 0;
	long long all = 1;
	for (int i = 0; i < n; i++)
	{
		char a[10];
		int p;
		scanf("%s %d", a, &p);
		if (v.find(p) == v.end())
		{
			v.insert(p);
			now.push_back(p);
		}
		else
		{
			if (l.find(-p) != l.end())
			{
				if ((*l.begin() != -p))
				{
					cout << 0;
					return 0;
				}
				l.erase(-p);
				all *= 2;
				all %= 1000000007;
				for (int j = 0; j < now.size(); j++)
				{
					if (now[j] < p)
						l.insert(-p);
					else
						r.insert(p);
				}
				now.clear();
				continue;
			}
			if (r.find(p) != r.end())
			{
				if ((*r.begin() != p))
				{
					cout << 0;
					return 0;
				}
				r.erase(p);
				all *= 2;
				all %= 1000000007;
				for (int j = 0; j < now.size(); j++)
				{
					if (now[j] < p)
						l.insert(-now[j]);
					else
						r.insert(now[j]);
				}
				now.clear();
				continue;
			}
			all *= 2;
			all %= 1000000007;
			for (int j = 0; j < now.size(); j++)
			{
				if (now[j] == p)
					continue;
				if (now[j] < p)
					l.insert(-now[j]);
				else
					r.insert(now[j]);
			}
			now.clear();
		}
	}
	if (l.size() == 0 && r.size() == 0)
	{
		all *= (now.size() + 1);
		all %= 1000000007;
	}
	else
	{
		int maxi = -1e9, mini = 1e9;
		if (l.size() != 0)
			maxi = -*l.begin();
		if (r.size() != 0)
			mini = *r.begin();
		int cnt = 0;
		for (int i = 0; i < now.size(); i++)
		{
			if (now[i] > maxi && now[i] < mini)
			{
				cnt++;
			}
		}
		all *= (cnt + 1);
		all %= 1000000007;
	}
	cout << all;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
int i,i0,n;
priority_queue<long long>q,q1;
priority_queue<long long,vector<long long>,greater<long long>>q2;
char op[10];
int main()
{
    while(scanf("%d",&n)!=EOF)
    {
        long long ans=1,tmp=1,l=0,r=308983067ll,m;
        for(i=1;i<=n;i++)
        {
            scanf("%s %lld",op,&m);
            if(op[1]=='D')
            {
                q.push(m);
                if(m>=l&&m<=r)tmp++;
            }
            else
            {
               // printf("%lld %lld %lld-------\n",ans,l,r);
                //if(q1.empty()==0)printf("q1 %d----\n",q1.top());
                //if(q2.empty()==0)printf("q2 %d----\n",q2.top());
                if(m<l||m>r)ans=0;
                if(m!=l&&m!=r)ans*=2;
                while(!q.empty())
                {
                    if(q.top()<m)q1.push(q.top());
                    else q2.push(q.top());
                    q.pop();
                }
                //else ans=0;
                ans%=mod;
                tmp=1;
                l=q1.empty()?0:q1.top();
                r=q2.empty()?308983067ll:q2.top();
            }
        }
        printf("%lld\n",tmp*ans%mod);
    }
    return 0;
}


#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int n,ans=1,res=1,x,mn=0,mx=1e9;
set<int>S;
set<int>::iterator it;
char s[10];
int main(){
	scanf("%d",&n);
	S.insert(1e9),S.insert(0);
	for(int i=1;i<=n;++i){
		scanf("%s%d",s,&x);
		if(s[1]=='D')S.insert(x),res+=(x>=mn&&x<=mx)?1:0;
		else{
			if(x<mn||x>mx)ans=0;
			if(x!=mn&&x!=mx)ans=2*ans%mod;
			S.erase(x);res=1;
			it=S.lower_bound(x);
			mx=*it;
			mn=*(--it);
		}
	}
	printf("%d\n",1ll*ans*res%mod);
}


#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
int i,i0,n;
priority_queue<long long>q,q1;
priority_queue<long long,vector<long long>,greater<long long>>q2;
char op[10];
int main()
{
    while(scanf("%d",&n)!=EOF)
    {
        long long ans=1,tmp=1,l=308983066ll,r=1,m;
        for(i=1;i<=n;i++)
        {
            scanf("%s %lld",op,&m);
            if(op[1]=='D')
            {
                q.push(m);
                tmp++;
                l=min(l,m),r=max(r,m);
            }
            else
            {
//                if(q1.empty()==0)printf("q1 %d----\n",q1.top());
//                if(q2.empty()==0)printf("q2 %d----\n",q2.top());
                if(m<l||m>r)ans=0;
                while(!q.empty())
                {
                    if(q.top()<=m)q1.push(q.top());
                    else q2.push(q.top());
                    q.pop();
                }
                if(q1.empty()==0&&q1.top()==m)q1.pop();
                //else ans=0;
                ans*=2;
                ans%=mod;
                tmp=1;
                l=q1.empty()?308983066ll:q1.top(),r=q2.empty()?1:q2.top();
            }
        }
        printf("%lld\n",tmp*ans%mod);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
int i,i0,n,m;
priority_queue<long long>q,q1;
priority_queue<long long,vector<long long>,greater<long long>>q2;
char op[10];
int main()
{
    while(scanf("%d",&n)!=EOF)
    {
        long long ans=1,tmp=1;
        for(i=1;i<=n;i++)
        {
            scanf("%s %d",op,&m);
            if(op[1]=='D')
            {
                if(q1.empty()==0&&m>=q1.top())q1.push(m);
                else if(q2.empty()==0&&m<=q2.top())q2.push(m);
                else q.push(m),tmp++;
            }
            else
            {
                if(q1.empty()==0&&m>q1.top()||q2.empty()==0&&m<q2.top())ans=0;
                while(!q.empty())
                {
                    if(q.top()<=m)q1.push(q.top());
                    else q2.push(q.top());
                    q.pop();
                }
                if(q1.empty()==0)q1.pop();
                else ans=0;
                ans*=2;
                ans%=mod;
                tmp=1;
            }
        }
        printf("%lld\n",tmp*ans%mod);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
int i,i0,n,m;
priority_queue<long long>q,q1;
priority_queue<long long,vector<long long>,greater<long long>>q2;
char op[10];
int main()
{
    while(scanf("%d",&n)!=EOF)
    {
        long long ans=1,tmp=1;
        for(i=1;i<=n;i++)
        {
            scanf("%s %d",op,&m);
            if(op[1]=='D')
            {
                if(q1.empty()==0&&m>=q1.top())q1.push(m);
                else if(q2.empty()==0&&m<=q2.top())q2.push(m);
                else q.push(m),tmp++;
            }
            else
            {
                if(q1.empty()==0&&m>q1.top()||q2.empty()==0&&m<q2.top())ans=0;
                bool f=0;
                while(!q.empty())
                {
                    if(q.top()<=m)q1.push(q.top());
                    else if(q.top()>m)q2.push(q.top());
                    q.pop();
                }
                q1.pop();
                ans*=2;
                ans%=mod;
                tmp=1;
            }
        }
        printf("%lld\n",tmp*ans%mod);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
int i,i0,n;
priority_queue<long long>q,q1;
priority_queue<long long,vector<long long>,greater<long long>>q2;
char op[10];
int main()
{
    while(scanf("%d",&n)!=EOF)
    {
        long long ans=1,tmp=1,l=0,r=308983067ll,m;
        for(i=1;i<=n;i++)
        {
            scanf("%s %lld",op,&m);
            if(op[1]=='D')
            {
                q.push(m);
                if(m>=l&&m<=r)tmp++;
            }
            else
            {
               // printf("%lld %lld %lld-------\n",ans,l,r);
                //if(q1.empty()==0)printf("q1 %d----\n",q1.top());
                //if(q2.empty()==0)printf("q2 %d----\n",q2.top());
                if(m<l||m>r)ans=0;
                if(m!=l&&m!=r)ans*=2;
                while(!q.empty())
                {
                    if(q.top()<=m)q1.push(q.top());
                    else q2.push(q.top());
                    q.pop();
                }
                if(q1.empty()==0&&q1.top()==m)q1.pop();
                //else ans=0;
                ans%=mod;
                tmp=1;
                l=q1.empty()?0:q1.top();
                r=q2.empty()?308983067ll:q2.top();
            }
        }
        printf("%lld\n",tmp*ans%mod);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
int i,i0,n;
priority_queue<long long>q,q1;
priority_queue<long long,vector<long long>,greater<long long>>q2;
char op[10];
int main()
{
    while(scanf("%d",&n)!=EOF)
    {
        long long ans=1,tmp=1,l=308983066ll,r=1,m;
        for(i=1;i<=n;i++)
        {
            scanf("%s %d",op,&m);
            if(op[1]=='D')
            {
                q.push(m);
                tmp++;
                l=min(l,m),r=max(r,m);
            }
            else
            {
//                if(q1.empty()==0)printf("q1 %d----\n",q1.top());
//                if(q2.empty()==0)printf("q2 %d----\n",q2.top());
                if(m<l||m>r)ans=0;
                while(!q.empty())
                {
                    if(q.top()<=m)q1.push(q.top());
                    else q2.push(q.top());
                    q.pop();
                }
                if(q1.empty()==0&&q1.top()==m)q1.pop();
                //else ans=0;
                ans*=2;
                ans%=mod;
                tmp=1;
                l=q1.empty()?308983066ll:q1.top(),r=q2.empty()?1:q2.top();
            }
        }
        printf("%lld\n",tmp*ans%mod);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
int i,i0,n;
priority_queue<long long>q,q1;
priority_queue<long long,vector<long long>,greater<long long>>q2;
char op[10];
int main()
{
    while(scanf("%d",&n)!=EOF)
    {
        long long ans=1,tmp=1,l=0,r=308983067ll,m;
        for(i=1;i<=n;i++)
        {
            scanf("%s %lld",op,&m);
            if(op[1]=='D')
            {
                q.push(m);
                if(m>=l&&m<=r)tmp++;
            }
            else
            {

                //if(q1.empty()==0)printf("q1 %d----\n",q1.top());
                //if(q2.empty()==0)printf("q2 %d----\n",q2.top());
                if(m<l||m>r)ans=0;
                if(m!=l&&m!=r)ans*=2;
                else if(m==l)q1.pop();
                else q2.pop();
                while(!q.empty())
                {
                    if(q.top()<m)q1.push(q.top());
                    if(q.top()>m) q2.push(q.top());
                    q.pop();
                }
                ans%=mod;
                tmp=1;
                l=q1.empty()?0:q1.top();
                r=q2.empty()?308983067ll:q2.top();
                // printf("%lld %lld %lld-------\n",ans,l,r);
            }
        }
        printf("%lld\n",tmp*ans%mod);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
int i,i0,n,m;
queue<int>q;
priority_queue<int>q1;
priority_queue<int,vector<int>,greater<int>>q2;
char op[10];
int main()
{
    while(scanf("%d",&n)!=EOF)
    {
        long long ans=1,tmp=1;
        for(i=1;i<=n;i++)
        {
            scanf("%s %d",op,&m);
            if(op[1]=='D')
            {
                if(q1.empty()==0&&m<=q1.top())q1.push(m);
                else if(q2.empty()==0&&m>=q2.top())q2.push(m);
                else q.push(m),tmp++;
            }
            else
            {
                if(q1.empty()==0&&m<q1.top()||q2.empty()==0&&m>q2.top())ans=0;
                if(q1.empty()==0&&m==q1.top())q1.pop();
                else if(q2.empty()==0&&m==q2.top())q2.pop();
                else ans=ans*2%mod;
                while(!q.empty())
                {
                    if(q.front()<m)q1.push(q.front());
                    if(q.front()>m) q2.push(q.front());
                    q.pop();
                }
                tmp=1;
            }
        }
        printf("%lld\n",tmp*ans%mod);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
int i,i0,n;
priority_queue<long long>q,q1;
priority_queue<long long,vector<long long>,greater<long long>>q2;
char op[10];
int main()
{
    while(scanf("%d",&n)!=EOF)
    {
        long long ans=1,tmp=1,l=0,r=308983067ll,m;
        for(i=1;i<=n;i++)
        {
            scanf("%s %lld",op,&m);
            if(op[1]=='D')
            {
                q.push(m);
                if(m>=l&&m<=r)tmp++;
            }
            else
            {
               // printf("%lld %lld %lld-------\n",ans,l,r);
                //if(q1.empty()==0)printf("q1 %d----\n",q1.top());
                //if(q2.empty()==0)printf("q2 %d----\n",q2.top());
                if(m<l||m>r)ans=0;
                if(m!=l&&m!=r)ans*=2;
                while(!q.empty())
                {
                    if(q.top()<m)q1.push(q.top());
                    if(q.top()>m) q2.push(q.top());
                    q.pop();
                }
                ans%=mod;
                tmp=1;
                l=q1.empty()?0:q1.top();
                r=q2.empty()?308983067ll:q2.top();
            }
        }
        printf("%lld\n",tmp*ans%mod);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
int i,i0,n;
priority_queue<long long>q,q1;
priority_queue<long long,vector<long long>,greater<long long>>q2;
char op[10];
int main()
{
    while(scanf("%d",&n)!=EOF)
    {
        long long ans=1,tmp=1,r=308983066ll,l=1,m;
        for(i=1;i<=n;i++)
        {
            scanf("%s %lld",op,&m);
            if(op[1]=='D')
            {
                q.push(m);
                tmp++;
                l=min(l,m),r=max(r,m);
            }
            else
            {
               // printf("%lld %lld %lld-------\n",ans,l,r);
                //if(q1.empty()==0)printf("q1 %d----\n",q1.top());
                //if(q2.empty()==0)printf("q2 %d----\n",q2.top());
                if(m<l||m>r)ans=0;
                while(!q.empty())
                {
                    if(q.top()<=m)q1.push(q.top());
                    else q2.push(q.top());
                    q.pop();
                }
                if(q1.empty()==0&&q1.top()==m)q1.pop();
                //else ans=0;
                ans*=2;
                ans%=mod;
                tmp=1;
                r=q2.empty()?308983066ll:q2.top(),l=q1.empty()?1:q1.top();
            }
        }
        printf("%lld\n",tmp*ans%mod);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
int i,i0,n,m;
priority_queue<long long>q,q1;
priority_queue<long long,vector<long long>,greater<long long>>q2;
char op[10];
int main()
{
    while(scanf("%d",&n)!=EOF)
    {
        long long ans=1,tmp=1;
        for(i=1;i<=n;i++)
        {
            scanf("%s %d",op,&m);
            if(op[1]=='D')
            {
                if(q1.empty()==0&&m<=q1.top())q1.push(m);
                else if(q2.empty()==0&&m>=q2.top())q2.push(m);
                else q.push(m),tmp++;
            }
            else
            {
//                if(q1.empty()==0)printf("q1 %d----\n",q1.top());
//                if(q2.empty()==0)printf("q2 %d----\n",q2.top());
                if(q1.empty()==0&&m<q1.top()||q2.empty()==0&&m>q2.top())ans=0;
                while(!q.empty())
                {
                    if(q.top()<=m)q1.push(q.top());
                    else q2.push(q.top());
                    q.pop();
                }
                if(q1.empty()==0&&q1.top()==m)q1.pop();
                ans*=2;
                ans%=mod;
                tmp=1;
            }
        }
        printf("%lld\n",tmp*ans%mod);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
int i,i0,n;
priority_queue<long long>q,q1;
priority_queue<long long,vector<long long>,greater<long long>>q2;
char op[10];
int main()
{
    while(scanf("%d",&n)!=EOF)
    {
        long long ans=1,tmp=1,l=308983066ll,r=1,m;
        for(i=1;i<=n;i++)
        {
            scanf("%s %lld",op,&m);
            if(op[1]=='D')
            {
                q.push(m);
                tmp++;
                l=min(l,m),r=max(r,m);
            }
            else
            {
//                if(q1.empty()==0)printf("q1 %d----\n",q1.top());
//                if(q2.empty()==0)printf("q2 %d----\n",q2.top());
                if(m<l||m>r)ans=0;
                while(!q.empty())
                {
                    if(q.top()<=m)q1.push(q.top());
                    else q2.push(q.top());
                    q.pop();
                }
                if(q1.empty()==0&&q1.top()==m)q1.pop();
                else ans=0;
                ans*=2;
                ans%=mod;
                tmp=1;
                l=308983066ll,r=1;
            }
        }
        printf("%lld\n",tmp*ans%mod);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
int i,i0,n;
priority_queue<long long>q,q1;
priority_queue<long long,vector<long long>,greater<long long>>q2;
char op[10];
int main()
{
    while(scanf("%d",&n)!=EOF)
    {
        long long ans=1,tmp=1,l=308983066ll,r=1,m;
        for(i=1;i<=n;i++)
        {
            scanf("%s %d",op,&m);
            if(op[1]=='D')
            {
                q.push(m);
                tmp++;
                l=min(l,m),r=max(r,m);
            }
            else
            {
//                if(q1.empty()==0)printf("q1 %d----\n",q1.top());
//                if(q2.empty()==0)printf("q2 %d----\n",q2.top());
                if(m<l||m>r)ans=0;
                while(!q.empty())
                {
                    if(q.top()<=m)q1.push(q.top());
                    else q2.push(q.top());
                    q.pop();
                }
                if(q1.empty()==0&&q1.top()==m)q1.pop();
                else ans=0;
                ans*=2;
                ans%=mod;
                tmp=1;
                l=q1.empty()?308983066ll:q1.top(),r=q2.empty()?1:q2.top();
            }
        }
        printf("%lld\n",tmp*ans%mod);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
int i,i0,n,m;
priority_queue<long long>q,q1;
priority_queue<long long,vector<long long>,greater<long long>>q2;
char op[10];
int main()
{
    while(scanf("%d",&n)!=EOF)
    {
        long long ans=1,tmp=1;
        for(i=1;i<=n;i++)
        {
            scanf("%s %d",op,&m);
            if(op[1]=='D')
            {
                if(q1.empty()==0&&m>=q1.top())q1.push(m);
                else if(q2.empty()==0&&m<=q2.top())q2.push(m);
                else q.push(m),tmp++;
            }
            else
            {
                //if(q1.empty()==0)printf("q1 %d----\n",q1.top());
               // if(q2.empty()==0)printf("q2 %d----\n",q2.top());
                if(q1.empty()==0&&m<q1.top()||q2.empty()==0&&m>q2.top())ans=0;
                while(!q.empty())
                {
                    if(q.top()<=m)q1.push(q.top());
                    else q2.push(q.top());
                    q.pop();
                }
                if(q1.empty()==0&&q1.top()==m)q1.pop();
                else ans=0;
                ans*=2;
                ans%=mod;
                tmp=1;
            }
        }
        printf("%lld\n",tmp*ans%mod);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
int i,i0,n,m;
priority_queue<long long>q,q1;
priority_queue<long long,vector<long long>,greater<long long>>q2;
char op[10];
int main()
{
    while(scanf("%d",&n)!=EOF)
    {
        long long ans=1,tmp=1;
        for(i=1;i<=n;i++)
        {
            scanf("%s %d",op,&m);
            if(op[1]=='D')
            {
                if(q1.empty()==0&&m<=q1.top())q1.push(m);
                else if(q2.empty()==0&&m>=q2.top())q2.push(m);
                else q.push(m),tmp++;
            }
            else
            {
                if(q1.empty()==0&&m<q1.top()||q2.empty()==0&&m>q2.top())ans=0;
                if(q1.empty()==0&&m==q1.top())q1.pop();
                else if(q2.empty()==0&&m==q2.top())q2.pop();
                else ans=ans*2%mod;
                while(!q.empty())
                {
                    if(q.top()<m)q1.push(q.top());
                    if(q.top()>m) q2.push(q.top());
                    q.pop();
                }
                tmp=1;
            }
        }
        printf("%lld\n",tmp*ans%mod);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
int i,i0,n,m;
priority_queue<long long>q,q1;
priority_queue<long long,vector<long long>,greater<long long>>q2;
char op[10];
int main()
{
    while(scanf("%d",&n)!=EOF)
    {
        long long ans=1,tmp=1;
        for(i=1;i<=n;i++)
        {
            scanf("%s %d",op,&m);
            if(op[1]=='D')
            {
                if(q1.empty()==0&&m<=q1.top())q1.push(m);
                else if(q2.empty()==0&&m>=q2.top())q2.push(m);
                else q.push(m),tmp++;
            }
            else
            {
                //if(q1.empty()==0)printf("q1 %d----\n",q1.top());
               // if(q2.empty()==0)printf("q2 %d----\n",q2.top());
                if(q1.empty()==0&&m<q1.top()||q2.empty()==0&&m>q2.top())ans=0;
                while(!q.empty())
                {
                    if(q.top()<=m)q1.push(q.top());
                    else q2.push(q.top());
                    q.pop();
                }
                if(q1.empty()==0&&q1.top()==m)q1.pop();
                else ans=0;
                ans*=2;
                ans%=mod;
                tmp=1;
            }
        }
        printf("%lld\n",tmp*ans%mod);
    }
    return 0;
}


#include <bits/stdc++.h>
using  namespace std;

#define endl '\n'
#define ll long long
#define rint register int

#define re register
#define pb(x) push_back(x);
#define ce(x) cout << x << '\n';

using db = long double;
using pll = pair < ll, ll >;
#define scan(a, n) 		for(int i = 0; i < n; i++)cin >> a[i];

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 1000000007
#define infl LLONG_MAX

#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase

int32_t main() {
	ios::sync_with_stdio(0); 		cin.tie(0); cout.tie(0);

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ll t, i, x, j, y, 	z, k = 1, n;
	z = 1;
	priority_queue<ll>pq, sell, buy;
	string s;

	tc(tt) {
		cin >> s >> x;

		if (s[1] == 'C') {
			k = 1;
			if (buy.size() == 0 && sell.size() == 0) {
				while (pq.size() && pq.top() != x) {
					sell.push(-pq.top());
					pq.pop();
				}

				if (pq.size() && pq.top() == x) {
					pq.pop();
					z *= 2;
					while (pq.size()) {
						buy.push(pq.top());
						pq.pop();
					}
				}
				else	z = 0;

			}
			else {
				if (buy.size() && buy.top() == x) {
					buy.pop();
				} else if (sell.size() && sell.top() == -x) {
					sell.pop();
				} else {

					while (pq.size() && pq.top() != x) {
						if (buy.size() && buy.top() >=  pq.top())	z = 0;

						sell.push(-pq.top());
						pq.pop();
					}

					if (pq.size() && pq.top() == x) {
						pq.pop();
						z *= 2;
						while (pq.size()) {
							if (sell.size() && -sell.top() <=  pq.top())	z = 0;

							buy.push(pq.top());
							pq.pop();
						}
					}
					else
						z = 0;
				}
			}

		} else {
			k++;
			if (buy.size() == 0 && sell.size() == 0) {
				pq.push(x);
			} else {
				if (sell.size() && -sell.top() <= x)	sell.push(-x);
				else if (buy.size() && buy.top() >= x)	buy.push(x);
				else  pq.push(x);
			}
		}
		z %= hell;
	}

	// if (pq.size())
	z *= (k );
	z %= hell;

	ce(z)
}


#include <bits/stdc++.h>
using  namespace std;

#define endl '\n'
#define ll long long
#define rint register int

#define re register
#define pb(x) push_back(x);
#define ce(x) cout << x << '\n';

using db = long double;
using pll = pair < ll, ll >;
#define scan(a, n) 		for(int i = 0; i < n; i++)cin >> a[i];

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 1000000007
#define infl LLONG_MAX

#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase

int32_t main() {
	ios::sync_with_stdio(0); 		cin.tie(0); cout.tie(0);

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ll t, i, x, j, y, 	z, k, n;
	z = 1;
	priority_queue<ll>pq, sell, buy;
	string s;

	tc(tt) {
		cin >> s >> x;

		if (s[1] == 'C') {
			if (buy.size() == 0 && sell.size() == 0) {
				while (pq.size() && pq.top() != x) {
					sell.push(-pq.top());
					pq.pop();
				}

				if (pq.size() && pq.top() == x) {
					pq.pop();
					z *= 2;
					while (pq.size()) {
						buy.push(pq.top());
						pq.pop();
					}
				}
				else	z = 0;

			}
			else {
				if (buy.size() && buy.top() == x) {
					buy.pop();
				} else if (sell.size() && sell.top() == -x) {
					sell.pop();
				} else {

					while (pq.size() && pq.top() != x) {
						if (buy.size() && buy.top() >=  pq.top())	z = 0;

						sell.push(-pq.top());
						pq.pop();
					}

					if (pq.size() && pq.top() == x) {
						pq.pop();
						z *= 2;
						while (pq.size()) {
							if (sell.size() && -sell.top() <=  pq.top())	z = 0;

							buy.push(pq.top());
							pq.pop();
						}
					}
					else
						z = 0;
				}
			}

		} else {
			if (buy.size() == 0 && sell.size() == 0) {
				pq.push(x);
			} else {
				if (sell.size() && -sell.top() <= x)	sell.push(-x);
				else if (buy.size() && buy.top() >= x)	buy.push(x);
				else  pq.push(x);
			}
		}
		z %= hell;
	}

	if (pq.size())	z *= (pq.size() + 1);
	z %= hell;

	ce(z)
}


#include <bits/stdc++.h>
using  namespace std;

#define endl '\n'
#define ll long long
#define rint register int

#define re register
#define pb(x) push_back(x);
#define ce(x) cout << x << '\n';

using db = long double;
using pll = pair < ll, ll >;
#define scan(a, n) 		for(int i = 0; i < n; i++)cin >> a[i];

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 1000000007
#define infl LLONG_MAX

#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase

int32_t main() {
	ios::sync_with_stdio(0); 		cin.tie(0); cout.tie(0);

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ll t, i, x, j, y, 	z, k = 1, n;
	z = 1;
	priority_queue<ll>pq, sell, buy;
	string s;

	tc(tt) {
		cin >> s >> x;

		if (s[1] == 'C') {
			k = 1;
			if (buy.size() == 0 && sell.size() == 0) {
				while (pq.size() && pq.top() != x) {
					sell.push(-pq.top());
					pq.pop();
				}

				if (pq.size() && pq.top() == x) {
					pq.pop();
					z *= 2;
					while (pq.size()) {
						buy.push(pq.top());
						pq.pop();
					}
				}
				else	z = 0;

			}
			else {
				if (buy.size() && buy.top() == x) {
					buy.pop();
				} else if (sell.size() && sell.top() == -x) {
					sell.pop();
				} else {

					while (pq.size() && pq.top() != x) {
						if (buy.size() && buy.top() >=  pq.top())	z = 0;

						sell.push(-pq.top());
						pq.pop();
					}

					if (pq.size() && pq.top() == x) {
						pq.pop();
						z *= 2;
						while (pq.size()) {
							if (sell.size() && -sell.top() <=  pq.top())	z = 0;

							buy.push(pq.top());
							pq.pop();
						}
					}
					else
						z = 0;
				}
			}

		} else {
			bool br = x <= (sell.size() == 0 ? hell :  -sell.top()) && x >= (buy.size() == 0 ? -hell : buy.top());

			k += br;
			if (buy.size() == 0 && sell.size() == 0) {
				pq.push(x);
			} else {
				if (sell.size() && -sell.top() <= x)	sell.push(-x);
				else if (buy.size() && buy.top() >= x)	buy.push(x);
				else  pq.push(x);
			}
		}
		z %= hell;
	}

	// if (pq.size())
	z *= (k );
	z %= hell;

	ce(z)
}


#include <bits/stdc++.h>
using  namespace std;

#define endl '\n'
#define ll long long
#define rint register int

#define re register
#define pb(x) push_back(x);
#define ce(x) cout << x << '\n';

using db = long double;
using pll = pair < ll, ll >;
#define scan(a, n) 		for(int i = 0; i < n; i++)cin >> a[i];

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 1000000007
#define infl LLONG_MAX

#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase

int32_t main() {
	ios::sync_with_stdio(0); 		cin.tie(0); cout.tie(0);

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ll t, i, x, j, y, 	z, k, n;
	z = 1;
	priority_queue<ll>pq, sell, buy;
	string s;

	tc(tt) {
		cin >> s >> x;

		if (s[1] == 'C') {
			if (buy.size() == 0 && sell.size() == 0) {
				while (pq.size() && pq.top() != x) {
					sell.push(-pq.top());
					pq.pop();
				}

				if (pq.size() && pq.top() == x) {
					pq.pop();
					z *= 2;
					while (pq.size()) {
						buy.push(pq.top());
						pq.pop();
					}
				}
				else	z = 0;

			}
			else {
				if (buy.size() && buy.top() == x) {
					buy.pop();
				} else if (sell.size() && sell.top() == -x) {
					sell.pop();
				} else {

					while (pq.size() && pq.top() != x) {
						if (buy.size() && buy.top() >=  pq.top())	z = 0;

						sell.push(-pq.top());
						pq.pop();
					}

					if (pq.size() && pq.top() == x) {
						pq.pop();
						z *= 2;
						while (pq.size()) {
							if (sell.size() && -sell.top() <=  pq.top())	z = 0;

							buy.push(pq.top());
							pq.pop();
						}
					}
					else
						z = 0;
				}
			}

		} else {
			if (buy.size() == 0 && sell.size() == 0) {
				pq.push(x);
			} else {
				if (sell.size() && -sell.top() <= x)	sell.push(-x);
				else if (buy.size() && buy.top() >= x)	buy.push(x);
				else  pq.push(x);
			}
		}
		z %= hell;
	}

	ce(z)
}


#include <bits/stdc++.h>
using  namespace std;

#define endl '\n'
#define ll long long
#define rint register int

#define re register
#define pb(x) push_back(x);
#define ce(x) cout << x << '\n';

using db = long double;
using pll = pair < ll, ll >;
#define scan(a, n) 		for(int i = 0; i < n; i++)cin >> a[i];

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 1000000007
#define infl LLONG_MAX

#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase

int32_t main() {
	ios::sync_with_stdio(0); 		cin.tie(0); cout.tie(0);

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ll t, i, x, j, y, 	z, k = 1, n;
	z = 1;
	priority_queue<ll>pq, sell, buy;
	string s;

	tc(tt) {
		cin >> s >> x;

		if (s[1] == 'C') {
			k = 1;
			if (buy.size() == 0 && sell.size() == 0) {
				while (pq.size() && pq.top() != x) {
					sell.push(-pq.top());
					pq.pop();
				}

				if (pq.size() && pq.top() == x) {
					pq.pop();
					z *= 2;
					while (pq.size()) {
						buy.push(pq.top());
						pq.pop();
					}
				}
				else	z = 0;

			}
			else {
				if (buy.size() && buy.top() == x) {
					buy.pop();
				} else if (sell.size() && sell.top() == -x) {
					sell.pop();
				} else {

					while (pq.size() && pq.top() != x) {
						if (buy.size() && buy.top() >=  pq.top())	z = 0;

						sell.push(-pq.top());
						pq.pop();
					}

					if (pq.size() && pq.top() == x) {
						pq.pop();
						z *= 2;
						while (pq.size()) {
							if (sell.size() && -sell.top() <=  pq.top())	z = 0;

							buy.push(pq.top());
							pq.pop();
						}
					}
					else
						z = 0;
				}
			}

		} else {
			bool br = x >= (sell.size() == 0 ? hell :  -sell.top()) && (buy.size() == 0 ? -hell : buy.top());

			k += br;
			if (buy.size() == 0 && sell.size() == 0) {
				pq.push(x);
			} else {
				if (sell.size() && -sell.top() <= x)	sell.push(-x);
				else if (buy.size() && buy.top() >= x)	buy.push(x);
				else  pq.push(x);
			}
		}
		z %= hell;
	}

	// if (pq.size())
	z *= (k );
	z %= hell;

	ce(z)
}


#include <bits/stdc++.h>
using namespace std;

const int N = 3633055;

#define int long long

const int mod = 1e9 + 7;

int n, p, x, mn = -1e9, mx = 1e9, res = 1;

set <int> S;

char ty[N];

main(void) {
	cin >> n;
	int ans = 1;
	for(int i = 1; i <= n; ++ i) {
		scanf("%s", ty + 1);
		scanf("%lld", &x);
		if(ty[2] == 'D') {
			if(x <= mx && x >= mn) ++ res;
			S.insert(x);
		}
		else {
			res = 1;
			if(x < mn || x > mx) {
				ans = 0; break;
			}
			S.erase(x);
			if(x > mn && x < mx) ans = ans * 2 % mod;
			set <int> :: iterator it = S.upper_bound(x);
			if(it == S.end()) mx = 1e9;else mx  = *it;
			if(it == S.begin()) mn = -1e9; else mn = *(-- it);
		}
	}
	cout << ans * res % mod << endl;
}


#include <bits/stdc++.h>
using  namespace std;

#define endl '\n'
#define ll long long
#define rint register int

#define re register
#define pb(x) push_back(x);
#define ce(x) cout << x << '\n';

using db = long double;
using pll = pair < ll, ll >;
#define scan(a, n) 		for(int i = 0; i < n; i++)cin >> a[i];

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 1000000007
#define infl LLONG_MAX

#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase

int32_t main() {
	ios::sync_with_stdio(0); 		cin.tie(0); cout.tie(0);

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ll t, i, x, j, y, 	z, k = 1, n;
	z = 1;
	priority_queue<ll>pq, sell, buy;
	string s;

	tc(tt) {
		cin >> s >> x;

		if (s[1] == 'C') {
			k = 1;
			if (buy.size() == 0 && sell.size() == 0) {
				while (pq.size() && pq.top() != x) {
					sell.push(-pq.top());
					pq.pop();
				}

				if (pq.size() && pq.top() == x) {
					pq.pop();
					z *= 2;
					while (pq.size()) {
						buy.push(pq.top());
						pq.pop();
					}
				}
				else	z = 0;

			}
			else {
				if (buy.size() && buy.top() == x) {
					buy.pop();
				} else if (sell.size() && sell.top() == -x) {
					sell.pop();
				} else {

					while (pq.size() && pq.top() != x) {
						if (buy.size() && buy.top() >=  pq.top())	z = 0;

						sell.push(-pq.top());
						pq.pop();
					}

					if (pq.size() && pq.top() == x) {
						pq.pop();
						z *= 2;
						while (pq.size()) {
							if (sell.size() && -sell.top() <=  pq.top())	z = 0;

							buy.push(pq.top());
							pq.pop();
						}
					}
					else
						z = 0;
				}
			}

		} else {
			bool br = x >= (sell.size() == 0 ? hell : x <= -sell.top()) && (buy.size() == 0 ? -hell : buy.top());

			k += br;
			if (buy.size() == 0 && sell.size() == 0) {
				pq.push(x);
			} else {
				if (sell.size() && -sell.top() <= x)	sell.push(-x);
				else if (buy.size() && buy.top() >= x)	buy.push(x);
				else  pq.push(x);
			}
		}
		z %= hell;
	}

	// if (pq.size())
	z *= (k );
	z %= hell;

	ce(z)
}


#include "bits/stdc++.h"
using namespace std;
#define int long long
#define ld long double
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define UPAR 10000000000000000

typedef pair<int, int> pi;
typedef vector<vector<int>> vv;

const int mod = 1000000007;

int32_t main()
{
    IOS;
    int n;
    cin >> n;
    set<int> s;
    int up = UPAR;
    int down = -UPAR;
    int tot = 0;
    int ans = 1;
    for (int i = 0; i < n; ++i)
    {
        string str;
        int x;
        cin >> str >> x;
        if(str.length() == 3){

                if(x < up && x > down)
                    tot++;
                s.insert(x);

        }else{

            if(x < up && x > down)
                ans *= 2;
            if(x < down || x > up)
                ans = 0;

            auto a = s.upper_bound(x);
            if(a == s.end())
                up = UPAR;
            else
                up = *a;

            a = s.lower_bound(x);
            if(a == s.begin())
                down = -UPAR;
            else
                down = *(--a);
            s.erase(x);
            tot = 0;
            ans %= mod;
        }
    }

    ans *= (tot+1);
    ans %= mod;
    cout << ans << endl;
}


#include "bits/stdc++.h"
using namespace std;
#define int long long
#define ld long double
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
//#define UPAR 10000000000000000

typedef pair<int, int> pi;
typedef vector<vector<int>> vv;
const int UPAR = 10000000000000000;
const int mod = 1000000007;

void solve(){
    int n;
    cin >> n;
    set<int> s;
    int up = UPAR;
    int down = -UPAR;
    int tot = 0;
    int ans = 1;
    for (int i = 0; i < n; ++i)
    {
        string str;
        int x;
        cin >> str >> x;
        if(str.length() == 3){
            if(s.count(x) == 0){
                if(x < up && x > down)
                    tot++;
                s.insert(x);
            }else{
                cout << 0 << endl;
                return;
            }
        }else{
            if(s.count(x) == 0){
                cout << 0 << endl;
                return;
            }
            if(x < up && x > down)
                ans *= 2;
            if(x < down || x > up)
                ans = 0;

            auto a = upper_bound(s.begin(), s.end(), x);
            if(a == s.end())
                up = UPAR;
            else
                up = *a;

            a = lower_bound(s.begin(), s.end(), x);
            if(a == s.begin())
                down = -UPAR;
            else
                down = *(--a);
            s.erase(x);
            tot = 0;
            ans %= mod;
        }
    }

    ans *= (tot+1);
    ans %= mod;
    cout << ans << endl;

}

int32_t main()
{
    IOS;
    solve();
}


#include "bits/stdc++.h"
using namespace std;
#define int long long
#define ld long double
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define UPAR 10000000000000000

typedef pair<int, int> pi;
typedef vector<vector<int>> vv;

const int mod = 1000000007;

void solve(){
    int n;
    cin >> n;
    set<int> s;
    int up = UPAR;
    int down = -UPAR;
    int tot = 0;
    int ans = 1;
    for (int i = 0; i < n; ++i)
    {
        string str;
        int x;
        cin >> str >> x;
        if(str.length() == 3){
            if(s.count(x) == 0){
                if(x < up && x > down)
                    tot++;
                s.insert(x);
            }else{
                cout << 0 << endl;
                return;
            }
        }else{
            if(s.count(x) == 0){
                cout << 0 << endl;
                return;
            }
            if(x < up && x > down)
                ans *= 2;
            if(x < down || x > up)
                ans = 0;

            auto a = upper_bound(s.begin(), s.end(), x);
            if(a == s.end())
                up = UPAR;
            else
                up = *a;

            a = lower_bound(s.begin(), s.end(), x);
            if(a == s.begin())
                down = -UPAR;
            else
                down = *(--a);
            s.erase(x);
            tot = 0;
            ans %= mod;
        }
    }

    ans *= (tot+1);
    ans %= mod;
    cout << ans << endl;

}

int32_t main()
{
    solve();
}


#include "bits/stdc++.h"
using namespace std;
#define int long long
#define ld long double
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define UPAR 10000000000000000

typedef pair<int, int> pi;
typedef vector<vector<int>> vv;

const int mod = 1000000007;

void solve(){
    int n;
    cin >> n;
    set<int> s;
    auto a = s.begin(), b = s.end(), last = s.begin();
    int flag = 0;
    int ans = 1;
    for (int i = 0; i < n; ++i)
    {
        string str;
        int x;
        cin >> str >> x;
        if(str.length() == 3){
            if(s.find(x) == b){
                s.insert(x);
                b = s.end();
            }else{
                cout << 0 << endl;
                return;
            }
        }else{
            if(s.count(x) == 0){
                cout << 0 << endl;
                return;
            }
            auto c = s.find(x);
            if(!flag){
                last = next(c);
                if(last == b){
                    s.erase(c);
                    last = s.end();
                }else{
                    int val = *last;
                    s.erase(c);
                    last = s.find(val);
                }
            }else{
                if(last == c){
                    last = next(c);
                    if(last == b){
                        s.erase(c);
                        last = s.end();
                    }else{
                        int val = *last;
                        s.erase(c);
                        last = s.find(val);
                    }
                }else if(next(c) == last){
                    if(last == b){
                        s.erase(c);
                        last = s.end();
                    }else{
                        int val = *last;
                        s.erase(c);
                        last = s.find(val);
                    }
                }else{
                    cout << 0 << endl;
                    return;
                }
            }
            b = s.end();
            flag = 1;
            ans *= 2;
            ans %= mod;
        }
    }
    cout << ans << endl;

}

int32_t main()
{
    solve();
}


#include "bits/stdc++.h"
using namespace std;
#define int long long
#define ld long double
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define UPAR 10000000000000000

typedef pair<int, int> pi;
typedef vector<vector<int>> vv;

const int mod = 1000000007;

void solve(){
    int n;
    cin >> n;
    set<int> s;
    auto a = s.begin(), b = s.end(), last = s.begin();
    int flag = 0;
    int ans = 1;
    for (int i = 0; i < n; ++i)
    {
        string str;
        int x;
        cin >> str >> x;
        if(str.length() == 3){
            if(s.find(x) == b){
                s.insert(x);
            }else{
                cout << 0 << endl;
                return;
            }
        }else{
            if(s.count(x) == 0){
                cout << 0 << endl;
                return;
            }
            auto c = s.find(x);
            if(!flag){
                last = next(c);
                if(last == b){
                    s.erase(c);
                    last = s.end();
                }else{
                    int val = *last;
                    s.erase(c);
                    last = s.find(val);
                }
            }else{
                if(last == c){
                    last = next(c);
                    if(last == b){
                        s.erase(c);
                        last = s.end();
                    }else{
                        int val = *last;
                        s.erase(c);
                        last = s.find(val);
                    }
                }else if(next(c) == last){
                    last = next(c);
                    if(last == b){
                        s.erase(c);
                        last = s.end();
                    }else{
                        int val = *last;
                        s.erase(c);
                        last = s.find(val);
                    }
                }else{
                    cout << 0 << endl;
                    return;
                }
            }
            flag = 1;
            ans *= 2;
            ans %= mod;
        }
    }
    cout << ans << endl;

}

int32_t main()
{
    solve();
}


#include "bits/stdc++.h"
using namespace std;
#define int long long
#define ld long double
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
//#define UPAR 10000000000000000

typedef pair<int, int> pi;
typedef vector<vector<int>> vv;
const int UPAR = 10000000000000000;
const int mod = 1000000007;

void solve(){
    int n;
    cin >> n;
    set<int> s;
    int up = UPAR;
    int down = -UPAR;
    int tot = 0;
    int ans = 1;
    for (int i = 0; i < n; ++i)
    {
        string str;
        int x;
        cin >> str >> x;
        if(str.length() == 3){
            if(s.count(x) == 0){
                if(x < up && x > down)
                    tot++;
                s.insert(x);
            }else{
                cout << 0 << endl;
                return;
            }
        }else{
            if(s.count(x) == 0){
                cout << 0 << endl;
                return;
            }
            if(x < up && x > down)
                ans *= 2;
            if(x < down || x > up)
                ans = 0;

            auto a = upper_bound(s.begin(), s.end(), x);
            if(a == s.end())
                up = UPAR;
            else
                up = *a;

            a = lower_bound(s.begin(), s.end(), x);
            if(a == s.begin())
                down = -UPAR;
            else
                down = *(--a);
            s.erase(x);
            tot = 0;
            ans %= mod;
        }
    }

    ans *= (tot+1);
    ans %= mod;
    cout << ans << endl;

}

int32_t main()
{
    solve();
}


#include "bits/stdc++.h"
using namespace std;
//#define int long long
#define ld long double
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
//#define UPAR 10000000000000000

typedef pair<int, int> pi;
typedef vector<vector<int>> vv;
const int UPAR = INT_MAX;
const int mod = 1000000007;

int32_t main()
{
    IOS;
    int n;
    cin >> n;
    set<int> s;
    int up = UPAR;
    int down = -UPAR;
    int tot = 0;
    int ans = 1;
    for (int i = 0; i < n; ++i)
    {
        string str;
        int x;
        cin >> str >> x;
        if(str.length() == 3){
            if(s.count(x) == 0){
                if(x < up && x > down)
                    tot++;
                s.insert(x);
            }else{
                cout << 0 << endl;
                return 0;
            }
        }else{
            if(s.count(x) == 0){
                cout << 0 << endl;
                return 0;
            }
            if(x < up && x > down)
                ans *= 2;
            if(x < down || x > up)
                ans = 0;

            auto a = upper_bound(s.begin(), s.end(), x);
            if(a == s.end())
                up = UPAR;
            else
                up = *a;

            a = lower_bound(s.begin(), s.end(), x);
            if(a == s.begin())
                down = -UPAR;
            else
                down = *(--a);
            s.erase(x);
            tot = 0;
            ans %= mod;
        }
    }

    ans *= (tot+1);
    ans %= mod;
    cout << ans << endl;
}


#include "bits/stdc++.h"
using namespace std;
#define int long long
#define ld long double
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define UPAR 10000000000000000

typedef pair<int, int> pi;
typedef vector<vector<int>> vv;

const int mod = 1000000007;

void solve(){
    int n;
    cin >> n;
    set<int> s;
    int up = UPAR;
    int down = -UPAR;
    int tot = 0;
    int ans = 1;
    for (int i = 0; i < n; ++i)
    {
        string str;
        int x;
        cin >> str >> x;
        if(str.length() == 3){
            if(s.find(x) == s.end()){
                if(x < up && x > down)
                    tot++;
                s.insert(x);
            }else{
                cout << 0 << endl;
                return;
            }
        }else{
            if(s.count(x) == 0){
                cout << 0 << endl;
                return;
            }
            if(x < up && x > down)
                ans *= 2;
            if(x < down || x > up)
                ans = 0;

            auto a = upper_bound(s.begin(), s.end(), x);
            if(a == s.end())
                up = UPAR;
            else
                up = *a;

            a = lower_bound(s.begin(), s.end(), x);
            if(a == s.begin())
                down = -UPAR;
            else
                down = *(--a);
            s.erase(x);
            tot = 0;
            ans %= mod;
        }
    }

    ans *= (tot+1);
    cout << ans%mod << endl;

}

int32_t main()
{
    solve();
}


#include "bits/stdc++.h"
using namespace std;
#define int long long
#define ld long double
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define UPAR 10000000000000000

typedef pair<int, int> pi;
typedef vector<vector<int>> vv;

const int mod = 1000000007;

void solve(){
    int n;
    cin >> n;
    set<int> s;
    auto a = s.begin(), b = s.end(), last = s.begin();
    int flag = 0;
    int ans = 1;
    for (int i = 0; i < n; ++i)
    {
        string str;
        int x;
        cin >> str >> x;
        b = s.end();
        if(str.length() == 3){
            if(s.find(x) == b){
                int val = -1;
                if(last != b)
                    val = *last;
                s.insert(x);
                if(val != -1){
                    last = s.find(val);
                }else
                    last = s.end();
            }else{
                cout << 0 << endl;
                return;
            }
        }else{
            if(s.count(x) == 0){
                cout << 0 << endl;
                return;
            }
            auto c = s.find(x);
            if(!flag){
                last = next(c);
                if(last == b){
                    s.erase(c);
                    last = s.end();
                }else{
                    int val = *last;
                    s.erase(c);
                    last = s.find(val);
                }
            }else{
                if(last == c){
                    last = next(c);
                    if(last == b){
                        s.erase(c);
                        last = s.end();
                    }else{
                        int val = *last;
                        s.erase(c);
                        last = s.find(val);
                    }
                }else if(next(c) == last){
                    if(last == b){
                        s.erase(c);
                        last = s.end();
                    }else{
                        int val = *last;
                        s.erase(c);
                        last = s.find(val);
                    }
                }else{
                    cout << 0 << endl;
                    return;
                }
            }
            flag = 1;
            ans *= 2;
            ans %= mod;
        }
    }
    cout << ans << endl;

}

int32_t main()
{
    solve();
}


#include "bits/stdc++.h"
using namespace std;
//#define int long long
#define ld long double
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
//#define UPAR 10000000000000000

typedef pair<int, int> pi;
typedef vector<vector<int>> vv;
const int UPAR = INT_MAX;
const int mod = 1000000007;

void solve(){
    int n;
    cin >> n;
    set<int> s;
    int up = UPAR;
    int down = -UPAR;
    int tot = 0;
    int ans = 1;
    for (int i = 0; i < n; ++i)
    {
        string str;
        int x;
        cin >> str >> x;
        if(str.length() == 3){
            if(s.count(x) == 0){
                if(x < up && x > down)
                    tot++;
                s.insert(x);
            }else{
                cout << 0 << endl;
                return;
            }
        }else{
            if(s.count(x) == 0){
                cout << 0 << endl;
                return;
            }
            if(x < up && x > down)
                ans *= 2;
            if(x < down || x > up)
                ans = 0;

            auto a = upper_bound(s.begin(), s.end(), x);
            if(a == s.end())
                up = UPAR;
            else
                up = *a;

            a = lower_bound(s.begin(), s.end(), x);
            if(a == s.begin())
                down = -UPAR;
            else
                down = *(--a);
            s.erase(x);
            tot = 0;
            ans %= mod;
        }
    }

    ans *= (tot+1);
    ans %= mod;
    cout << ans << endl;

}

int32_t main()
{
    IOS;
    solve();
}


#include "bits/stdc++.h"
using namespace std;
#define int long long
#define ld long double
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define UPAR 10000000000000000

typedef pair<int, int> pi;
typedef vector<vector<int>> vv;

const int mod = 998244353;

void solve(){
    int n;
    cin >> n;
    set<int> s;
    auto a = s.begin(), b = s.end(), last = s.begin();
    int flag = 0;
    int ans = 1;
    for (int i = 0; i < n; ++i)
    {
        string str;
        int x;
        cin >> str >> x;
        if(str.length() == 3){
            if(s.find(x) == b){
                s.insert(x);
            }else{
                cout << 0 << endl;
                return;
            }
        }else{
            if(s.count(x) == 0){
                cout << 0 << endl;
                return;
            }
            auto c = s.find(x);
            if(!flag){
                last = next(c);
                s.erase(c);
            }else{
                if(last == c){
                    last = next(c);
                    s.erase(c);
                }else if(next(c) == last){
                    s.erase(c);
                }else{
                    cout << 0 << endl;
                    return;
                }
            }
            flag = 1;
            ans *= 2;
        }
    }
    cout << ans << endl;

}

int32_t main()
{
    solve();
}


#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define ld long double
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
//#define UPAR 10000000000000000

typedef pair<int, int> pi;
typedef vector<vector<int>> vv;
const int UPAR = INT_MAX - 10;
const int mod = 1000000007;

int32_t main()
{
    IOS;
    int n;
    cin >> n;
    set<int> s;
    int up = UPAR;
    int down = -UPAR;
    int tot = 0;
    int ans = 1;
    for (int i = 0; i < n; ++i)
    {
        string str;
        int x;
        cin >> str >> x;
        if(str.length() == 3){
            if(s.count(x) == 0){
                if(x < up && x > down)
                    tot++;
                s.insert(x);
            }else{
                cout << 0 << endl;
                return 0;
            }
        }else{
            if(s.count(x) == 0){
                cout << 0 << endl;
                return 0;
            }
            if(x < up && x > down)
                ans *= 2;
            if(x < down || x > up)
                ans = 0;

            auto a = upper_bound(s.begin(), s.end(), x);
            if(a == s.end())
                up = UPAR;
            else
                up = *a;

            a = lower_bound(s.begin(), s.end(), x);
            if(a == s.begin())
                down = -UPAR;
            else
                down = *(--a);
            s.erase(x);
            tot = 0;
            ans %= mod;
        }
    }

    ans *= (tot+1);
    ans %= mod;
    cout << ans << endl;
}


#include "bits/stdc++.h"
using namespace std;
//#define int long long
#define ld long double
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
//#define UPAR 10000000000000000

typedef pair<int, int> pi;
typedef vector<vector<int>> vv;
const int UPAR = 4e8;
const int mod = 1000000007;

int32_t main()
{
    IOS;
    int n;
    cin >> n;
    set<int> s;
    int up = UPAR;
    int down = -UPAR;
    int tot = 0;
    int ans = 1;
    for (int i = 0; i < n; ++i)
    {
        string str;
        int x;
        cin >> str >> x;
        if(str.length() == 3){

                if(x < up && x > down)
                    tot++;
                s.insert(x);

        }else{

            if(x < up && x > down)
                ans *= 2;
            if(x < down || x > up)
                ans = 0;

            auto a = upper_bound(s.begin(), s.end(), x);
            if(a == s.end())
                up = UPAR;
            else
                up = *a;

            a = lower_bound(s.begin(), s.end(), x);
            if(a == s.begin())
                down = -UPAR;
            else
                down = *(--a);
            s.erase(x);
            tot = 0;
            ans %= mod;
        }
    }

    ans *= (tot+1);
    ans %= mod;
    cout << ans << endl;
}


#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;

int main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    set<int> all;
    int mod = 1000000007;
    int mi = 0;
    int ma = mod;
    int ans = 1;
    int k = 0;
    for (int i = 0; i < n; ++i) {
        string s;
        int a;
        cin >> s >> a;
        if (s == "ADD") {
            all.insert(a);
        } else {
            ++k;
            if (mi < a && a < ma) {
                ans *= 2;
                ans %= mod;
            }
            if (a > ma) {
                ans = 0;
                break;
            }
            if (a < mi) {
                ans = 0;
                break;
            }
            all.erase(a);
            auto it = all.lower_bound(a);
            if (it != all.end()) {
                ma = *it;
            }
            if (it != all.begin()) {
                --it;
                mi = *it;
            }
        }
    }
    if (k == 0) {
        ans = n;
    }
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;

int main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    set<int> all;
    int mod = 1000000007;
    int mi = 0;
    int ma = mod;
    int ans = 1;
    for (int i = 0; i < n; ++i) {
        string s;
        int a;
        cin >> s >> a;
        if (s == "ADD") {
            all.insert(a);
        } else {
            if (mi < a && a < ma) {
                ans *= 2;
                ans %= mod;
            }
            if (a > ma) {
                ans = 0;
                break;
            }
            if (a < mi) {
                ans = 0;
                break;
            }
            all.erase(a);
            auto it = all.lower_bound(a);
            if (it != all.end()) {
                ma = *it;
            }
            if (it != all.begin()) {
                --it;
                mi = *it;
            }
        }
    }
    if (ans == 1) {
        ans = 2;
    }
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;

int main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    set<int> all;
    int mod = 1000000007;
    int mi = 0;
    int ma = mod;
    int ans = 1;
    for (int i = 0; i < n; ++i) {
        string s;
        int a;
        cin >> s >> a;
        if (s == "ADD") {
            all.insert(a);
        } else {
            if (mi < a && a < ma) {
                ans *= 2;
                ans %= mod;
            }
            if (a > ma) {
                ans = 0;
                break;
            }
            if (a < mi) {
                ans = 0;
                break;
            }
            all.erase(a);
            auto it = all.lower_bound(a);
            if (it != all.end()) {
                ma = *it;
            }
            if (it != all.begin()) {
                --it;
                mi = *it;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;

int main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    set<int> all;
    int mod = 1000000007;
    int mi = 0;
    int ma = mod;
    int ans = 1;
    int k = 0;
    for (int i = 0; i < n; ++i) {
        string s;
        int a;
        cin >> s >> a;
        if (s == "ADD") {
            all.insert(a);
            if (mi < a && a < ma) {
                ++k;
            }
        } else {
            k = 0;
            if (mi < a && a < ma) {
                ans *= 2;
                ans %= mod;
            }
            if (a > ma) {
                ans = 0;
                break;
            }
            if (a < mi) {
                ans = 0;
                break;
            }
            all.erase(a);
            auto it = all.lower_bound(a);
            if (it != all.end()) {
                ma = *it;
            } else {
                ma = mod;
            }
            if (it != all.begin()) {
                --it;
                mi = *it;
            } else {
                mi = 0;
            }
        }
    }
    ans *= k + 1;
    ans %= mod;
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;

int main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    set<int> all;
    int mod = 1000000007;
    int mi = 0;
    int ma = mod;
    int ans = 1;
    int k = 0;
    for (int i = 0; i < n; ++i) {
        string s;
        int a;
        cin >> s >> a;
        if (s == "ADD") {
            all.insert(a);
        } else {
            ++k;
            if (mi < a && a < ma) {
                ans *= 2;
                ans %= mod;
            }
            if (a > ma) {
                ans = 0;
                break;
            }
            if (a < mi) {
                ans = 0;
                break;
            }
            all.erase(a);
            auto it = all.lower_bound(a);
            if (it != all.end()) {
                ma = *it;
            } else {
                ma = mod;
            }
            if (it != all.begin()) {
                --it;
                mi = *it;
            } else {
                mi = 0;
            }
        }
    }
    if (k == 0) {
        ans = n;
    }
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;

int main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    set<int> all;
    int mod = 1000000007;
    int mi = 0;
    int ma = mod;
    ll ans = 1;
    int k = 0;
    for (int i = 0; i < n; ++i) {
        string s;
        int a;
        cin >> s >> a;
        if (s == "ADD") {
            all.insert(a);
            if (mi < a && a < ma) {
                ++k;
            }
        } else {
            k = 0;
            if (mi < a && a < ma) {
                ans *= 2;
                ans %= mod;
            }
            if (a > ma) {
                ans = 0;
                break;
            }
            if (a < mi) {
                ans = 0;
                break;
            }
            all.erase(a);
            auto it = all.lower_bound(a);
            if (it != all.end()) {
                ma = *it;
            } else {
                ma = mod;
            }
            if (it != all.begin()) {
                --it;
                mi = *it;
            } else {
                mi = 0;
            }
        }
    }
    ans *= k + 1;
    ans %= mod;
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;

int main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    set<int> all;
    int mod = 1000000007;
    int mi = 0;
    int ma = mod;
    int ans = 1;
    int k = 0;
    for (int i = 0; i < n; ++i) {
        string s;
        int a;
        cin >> s >> a;
        if (s == "ADD") {
            all.insert(a);
        } else {
            ++k;
            if (mi < a && a < ma) {
                ans *= 2;
                ans %= mod;
            }
            if (a > ma) {
                ans = 0;
                break;
            }
            if (a < mi) {
                ans = 0;
                break;
            }
            all.erase(a);
            auto it = all.lower_bound(a);
            if (it != all.end()) {
                ma = *it;
            } else {
                ma = mod;
            }
            if (it != all.begin()) {
                --it;
                mi = *it;
            } else {
                mi = 0;
            }
        }
    }
    if (k == 0) {
        ans = n + 1;
    }
    cout << ans << endl;
    return 0;
}


#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

const ll mod = 1e9 + 7;

int n;
ll ways = 1;

set <int> buy, sell, undefined;

int main() {
  scanf("%d", &n);

  buy.insert(INT_MIN);
  sell.insert(INT_MAX);

  for (int i = 0; i < n; ++i) {
    char s[10];
    int p;

    scanf(" %s %d", s, &p);

    if (!ways) continue;

    if (s[1] == 'D') { // ADD
      int buyMax = *(--buy.end());
      int sellMin = *sell.begin();

      if (p < buyMax) buy.insert(p);
      else if (p > sellMin) sell.insert(p);
      else undefined.insert(p);
    }
    else { // ACCEPT
      if (buy.find(p) != buy.end()) {
        int buyMax = *(--buy.end());
        if (buyMax != p) { ways = 0; continue; }
        for (auto k: undefined) sell.insert(k);
        undefined.clear();
        buy.erase(p);
      }
      else if (sell.find(p) != sell.end()) {
        int sellMin = *sell.begin();
        if (sellMin != p) { ways = 0; continue; }
        for (auto k: undefined) buy.insert(k);
        undefined.clear();
        sell.erase(p);
      }
      else {
        int buyMax = *(--buy.end());
        int sellMin = *sell.begin();

        if (buyMax < p && p < sellMin) {
          ways = (ways * 2LL) % mod;

          for (auto k: undefined)
            if (k < p)
              buy.insert(k);
            else
              if (k > p)
                sell.insert(k);
          undefined.clear();
        }
        else
          ways = 0;
      }
    }
  }

  printf("%lld\n", ways);
}


#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

const ll mod = 1e9 + 7;

int n;
ll ways = 1;

set <int> buy, sell, undefined;

int main() {
  scanf("%d", &n);

  buy.insert(INT_MIN);
  sell.insert(INT_MAX);

  for (int i = 0; i < n; ++i) {
    char s[10];
    int p;

    scanf(" %s %d", s, &p);

    if (!ways) continue;

    if (s[1] == 'D') { // ADD
      int buyMax = *(--buy.end());
      int sellMin = *sell.begin();

      if (p < buyMax) buy.insert(p);
      else if (p > sellMin) sell.insert(p);
      else undefined.insert(p);
    }
    else { // ACCEPT
      if (buy.find(p) != buy.end()) {
        int buyMax = *(--buy.end());
        if (buyMax != p) { ways = 0; continue; }
        for (auto k: undefined) sell.insert(k);
        undefined.clear();
        buy.erase(p);
      }
      else if (sell.find(p) != sell.end()) {
        int sellMin = *sell.begin();
        if (sellMin != p) { ways = 0; continue; }
        for (auto k: undefined) buy.insert(k);
        undefined.clear();
        sell.erase(p);
      }
      else {
        ways = (ways * 2LL) % mod;
        for (auto k: undefined)
          if (k < p)
            buy.insert(k);
          else
            if (k > p)
              sell.insert(k);
        undefined.clear();
      }
    }
  }

  printf("%lld\n", ways);
}


#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

const ll mod = 1e9 + 7;

int n;
ll ways = 1;

set <int> buy, sell, undefined;

int main() {
  scanf("%d", &n);

  buy.insert(INT_MIN);
  sell.insert(INT_MAX);

  for (int i = 0; i < n; ++i) {
    char s[10];
    int p;

    scanf(" %s %d", s, &p);

    if (!ways) continue;

    if (s[1] == 'D') { // ADD
      int buyMax = *(--buy.end());
      int sellMin = *sell.begin();

      if (p < buyMax) buy.insert(p);
      else if (p > sellMin) sell.insert(p);
      else undefined.insert(p);
    }
    else { // ACCEPT
      if (buy.find(p) != buy.end()) {
        int buyMax = *(--buy.end());
        if (buyMax != p) { ways = 0; continue; }
        for (auto k: undefined) sell.insert(k);
        undefined.clear();
        buy.erase(p);
      }
      else if (sell.find(p) != sell.end()) {
        int sellMin = *sell.begin();
        if (sellMin != p) { ways = 0; continue; }
        for (auto k: undefined) buy.insert(k);
        undefined.clear();
        sell.erase(p);
      }
      else {
        ways = (ways * 2LL) % mod;

        for (auto k: undefined)
          if (k < p)
            buy.insert(k);
          else
            if (k > p)
              sell.insert(k);
        undefined.clear();
      }
    }
  }

  if (!undefined.empty()) {
    int x = undefined.size();
    ll total = x;

    ways = (ways * total) % mod;
  }

  printf("%lld\n", ways);
}


#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

const ll mod = 1e9 + 7;

int n;
ll ways = 1;

set <int> buy, sell, undefined;

int main() {
  scanf("%d", &n);

  buy.insert(INT_MIN);
  sell.insert(INT_MAX);

  for (int i = 0; i < n; ++i) {
    char s[10];
    int p;

    scanf(" %s %d", s, &p);

    if (!ways) continue;

    if (s[1] == 'D') { // ADD
      int buyMax = *(--buy.end());
      int sellMin = *sell.begin();

      if (p < buyMax) buy.insert(p);
      else if (p > sellMin) sell.insert(p);
      else undefined.insert(p);
    }
    else { // ACCEPT
      if (buy.find(p) != buy.end()) {
        int buyMax = *(--buy.end());
        if (buyMax != p) { ways = 0; continue; }
        for (auto k: undefined) sell.insert(k);
        undefined.clear();
        buy.erase(p);
      }
      else if (sell.find(p) != sell.end()) {
        int sellMin = *sell.begin();
        if (sellMin != p) { ways = 0; continue; }
        for (auto k: undefined) buy.insert(k);
        undefined.clear();
        sell.erase(p);
      }
      else {
        ways = (ways * 2LL) % mod;

        for (auto k: undefined)
          if (k < p)
            buy.insert(k);
          else
            if (k > p)
              sell.insert(k);
        undefined.clear();
      }
    }
  }

  if (!undefined.empty()) {
    int x = undefined.size();
    ll total = 2 * x;

    ways = (ways * total) % mod;
  }

  printf("%lld\n", ways);
}


#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

const ll mod = 1e9 + 7;

int n;
ll ways = 1;

set <int> buy, sell, undefined;

int main() {
  scanf("%d", &n);

  buy.insert(INT_MIN);
  sell.insert(INT_MAX);

  for (int i = 0; i < n; ++i) {
    char s[10];
    int p;

    scanf(" %s %d", s, &p);

    if (!ways) continue;

    if (s[1] == 'D') { // ADD
      int buyMax = *(--buy.end());
      int sellMin = *sell.begin();

      if (p < buyMax) buy.insert(p);
      else if (p > sellMin) sell.insert(p);
      else undefined.insert(p);
    }
    else { // ACCEPT
      if (buy.find(p) != buy.end()) {
        int buyMax = *(--buy.end());
        if (buyMax != p) { ways = 0; continue; }
        for (auto k: undefined) sell.insert(k);
        undefined.clear();
        buy.erase(p);
      }
      else if (sell.find(p) != sell.end()) {
        int sellMin = *sell.begin();
        if (sellMin != p) { ways = 0; continue; }
        for (auto k: undefined) buy.insert(k);
        undefined.clear();
        sell.erase(p);
      }
      else {
        ways = (ways * 2LL) % mod;

        for (auto k: undefined)
          if (k < p)
            buy.insert(k);
          else
            if (k > p)
              sell.insert(k);
        undefined.clear();
      }
    }
  }

  if (!undefined.empty()) {
    int x = undefined.size();

    for (int i = 0; i < x; ++i)
      ways = (ways * 2LL) % mod;
  }

  printf("%lld\n", ways);
}


#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

const ll mod = 1e9 + 7;

int n;
ll ways = 1;

set <int> buy, sell, undefined;

int main() {
  scanf("%d", &n);

  buy.insert(INT_MIN);
  sell.insert(INT_MAX);

  for (int i = 0; i < n; ++i) {
    char s[10];
    int p;

    scanf(" %s %d", s, &p);

    if (!ways) continue;

    if (s[1] == 'D') { // ADD
      int buyMax = *(--buy.end());
      int sellMin = *sell.begin();

      if (p < buyMax) buy.insert(p);
      else if (p > sellMin) sell.insert(p);
      else undefined.insert(p);
    }
    else { // ACCEPT
      if (buy.find(p) != buy.end()) {
        int buyMax = *(--buy.end());
        if (buyMax != p) { ways = 0; continue; }
        for (auto k: undefined) sell.insert(k);
        undefined.clear();
        buy.erase(p);
      }
      else if (sell.find(p) != sell.end()) {
        int sellMin = *sell.begin();
        if (sellMin != p) { ways = 0; continue; }
        for (auto k: undefined) buy.insert(k);
        undefined.clear();
        sell.erase(p);
      }
      else {
        ways = (ways * 2LL) % mod;

        for (auto k: undefined)
          if (k < p)
            buy.insert(k);
          else
            if (k > p)
              sell.insert(k);
        undefined.clear();
      }
    }
  }

  if (!undefined.empty()) {
    int x = undefined.size();
    ll total = x + 1;

    ways = (ways * total) % mod;
  }

  printf("%lld\n", ways);
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<queue>
#include<vector>
#include<string.h>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<fstream>
#include<cstdlib>
#include<ctime>
#include<list>
#include<climits>
#include<bitset>
using namespace std;
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fopen freopen("input.in", "r", stdin);freopen("output.in", "w", stdout);
#define left asfdasdasdfasdfsdfasfsdfasfdas1
#define tan asfdasdasdfasdfasfdfasfsdfasfdas
typedef long long ll;
typedef unsigned int un;
const int desll[4][2]={{0,1},{0,-1},{1,0},{-1,0}};
const ll mod=1e9+7;
const int maxn=4e5+7;
const int maxm=1e6+7;
const double eps=1e-4;
int m,n;
int ar[maxn];
set<int> se;
char ch[100];
int maxx=308983067;

int main()
{
    scanf("%d",&n);
    int ans=1;
    int l=0,r=maxx;
    bool ma=true;
    int ins=0;
    for(int i=0;i<n;i++){
        int x;
        scanf("%s",ch);
        scanf("%d",&x);
        if(ch[1]=='D'){
            if(se.count(x)==0 && l<x && x<r){
                se.insert(x);
                ins++;
            }
            else if(se.count(x)==1){
                ma=0;
            }
            else{
                se.insert(x);
            }
        }
        else{
            if(se.count(x)==1 && x<=r && x>=l){
                set<int>::iterator iter=se.find(x);
                if(iter==se.begin())l=0;
                else{
                    iter--;
                    l=*iter;
                    iter++;
                }
                se.erase(iter++);
                if(iter==se.end())r=maxx;
                else{
                    r=*iter;
                }
                if(x!=l&&x!=r)ans = ans*2%mod;
            }
            else{
                //cout<<"x = "<<x<<endl;
                //if(x<=r && x>=l)cout<<"yes\n\n";
                ///else cout<<"no\n\n";
                ma=0;
            }
            ins=0;
        }
        //cout<<i<<" "<<l<<" "<<r<<endl;
    }
    if(ma)printf("%d\n",(ans+ins)%mod);
    else printf("0\n");

    return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<queue>
#include<vector>
#include<string.h>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<fstream>
#include<cstdlib>
#include<ctime>
#include<list>
#include<climits>
#include<bitset>
using namespace std;
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fopen freopen("input.in", "r", stdin);freopen("output.in", "w", stdout);
#define left asfdasdasdfasdfsdfasfsdfasfdas1
#define tan asfdasdasdfasdfasfdfasfsdfasfdas
typedef long long ll;
typedef unsigned int un;
const int desll[4][2]={{0,1},{0,-1},{1,0},{-1,0}};
const ll mod=1e9+7;
const int maxn=4e5+7;
const int maxm=1e6+7;
const double eps=1e-4;
int m,n;
int ar[maxn];
set<int> se;
char ch[100];
int maxx=308983067;

int main()
{
    scanf("%d",&n);
    int ans=1;
    int l=0,r=maxx;
    bool ma=true;
    int ins=0;
    for(int i=0;i<n;i++){
        int x;
        scanf("%s",ch);
        scanf("%d",&x);
        if(ch[1]=='D'){
            if(se.count(x)==0 && l<x && x<r){
                se.insert(x);
                ins++;
            }
            else if(se.count(x)==1){
                ma=0;
            }
            else{
                se.insert(x);
            }
        }
        else{
            if(se.count(x)==1 && x<=r && x>=l){
                if(x!=l&&x!=r)ans = ans*2%mod;
                set<int>::iterator iter=se.find(x);
                if(iter==se.begin())l=0;
                else{
                    iter--;
                    l=*iter;
                    iter++;
                }
                se.erase(iter++);
                if(iter==se.end())r=maxx;
                else{
                    r=*iter;
                }
            }
            else{
                //cout<<"x = "<<x<<endl;
                //if(x<=r && x>=l)cout<<"yes\n\n";
                ///else cout<<"no\n\n";
                ma=0;
            }
            ins=0;
        }
        //cout<<i<<" "<<l<<" "<<r<<endl;
    }
    if(ins)ins++;
    if(ma)printf("%d\n",(ans+ins)%mod);
    else printf("0\n");

    return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<queue>
#include<vector>
#include<string.h>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<fstream>
#include<cstdlib>
#include<ctime>
#include<list>
#include<climits>
#include<bitset>
using namespace std;
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fopen freopen("input.in", "r", stdin);freopen("output.in", "w", stdout);
#define left asfdasdasdfasdfsdfasfsdfasfdas1
#define tan asfdasdasdfasdfasfdfasfsdfasfdas
typedef long long ll;
typedef unsigned int un;
const int desll[4][2]={{0,1},{0,-1},{1,0},{-1,0}};
const ll mod=1e9+7;
const int maxn=4e5+7;
const int maxm=1e6+7;
const double eps=1e-4;
int m,n;
int ar[maxn];
set<int> se;
char ch[100];
int maxx=308983067;

int main()
{
    scanf("%d",&n);
    int ans=1;
    int l=0,r=maxx;
    bool ma=true;
    int ins=0;
    int test=0;
    for(int i=0;i<n;i++){
        int x;
        scanf("%s",ch);
        scanf("%d",&x);
        if(ch[1]=='D'){
            if(se.count(x)==0 && l<x && x<r){
                se.insert(x);
                ins++;
            }
            else if(se.count(x)==1){
                ma=0;
            }
            else{
                se.insert(x);
            }
            test++;
        }
        else{
            if(se.count(x)==1 && x<=r && x>=l){
                if(x!=l&&x!=r)ans = ans*2%mod;
                set<int>::iterator iter=se.find(x);
                if(iter==se.begin())l=0;
                else{
                    iter--;
                    l=*iter;
                    iter++;
                }
                se.erase(iter++);
                if(iter==se.end())r=maxx;
                else{
                    r=*iter;
                }
            }
            else{
                //cout<<"x = "<<x<<endl;
                //if(x<=r && x>=l)cout<<"yes\n\n";
                ///else cout<<"no\n\n";
                ma=0;
            }
            ins=0;
            test=0;
        }
        //cout<<i<<" "<<l<<" "<<r<<endl;
    }
    if(ins)ins++;
    if(ma){
        ans = (ans+ins)%mod;
    }
    if(ma && ans==771819115)cout<<"ins = "<<ins<<" "<<test<<endl;
    if(ma)printf("%d\n",ans);
    else printf("0\n");

    return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<queue>
#include<vector>
#include<string.h>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<fstream>
#include<cstdlib>
#include<ctime>
#include<list>
#include<climits>
#include<bitset>
using namespace std;
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fopen freopen("input.in", "r", stdin);freopen("output.in", "w", stdout);
#define left asfdasdasdfasdfsdfasfsdfasfdas1
#define tan asfdasdasdfasdfasfdfasfsdfasfdas
typedef long long ll;
typedef unsigned int un;
const int desll[4][2]={{0,1},{0,-1},{1,0},{-1,0}};
const ll mod=1e9+7;
const int maxn=4e5+7;
const int maxm=1e6+7;
const double eps=1e-4;
int m,n;
int ar[maxn];
set<int> se;
char ch[100];
int maxx=308983067;

int main()
{
    scanf("%d",&n);
    int ans=1;
    int l=0,r=maxx;
    bool ma=true;
    int ins=0;
    int test=0;
    for(int i=0;i<n;i++){
        int x;
        scanf("%s",ch);
        scanf("%d",&x);
        if(ch[1]=='D'){
            if(se.count(x)==0 && l<x && x<r){
                se.insert(x);
                ins++;
            }
            else if(se.count(x)==1){
                ma=0;
            }
            else{
                se.insert(x);
            }
            test++;
        }
        else{
            if(se.count(x)==1 && x<=r && x>=l){
                if(x!=l&&x!=r)ans = ans*2%mod;
                set<int>::iterator iter=se.find(x);
                if(iter==se.begin())l=0;
                else{
                    iter--;
                    l=*iter;
                    iter++;
                }
                se.erase(iter++);
                if(iter==se.end())r=maxx;
                else{
                    r=*iter;
                }
            }
            else{
                //cout<<"x = "<<x<<endl;
                //if(x<=r && x>=l)cout<<"yes\n\n";
                ///else cout<<"no\n\n";
                ma=0;
            }
            ins=0;
            test=0;
        }
        //cout<<i<<" "<<l<<" "<<r<<endl;
    }
    if(ins){
        ans = 1LL*ans*(ins+1)%mod;
    }
    if(ma)printf("%d\n",ans);
    else printf("0\n");

    return 0;
}