#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;


typedef int weight;
struct edge {
	int src, dst;
    weight aweight;
	edge(int src, int dst, weight weight_) :
		src(src), dst(dst), aweight(weight_) { }
};
struct dscc {
public:

	//belongs,newedges
	pair<vector<vector<int>>, vector<vector<int>>>get(const vector<vector<int>>&edges) {
		nums.resize(edges.size());
		fill(nums.begin(), nums.end(), -1);
		vector<vector<int>>revedges(edges.size());
		for (int i = 0; i < edges.size(); ++i) {
			for (auto j : edges[i]) {
				revedges[j].push_back(i);
			}
		}
		int num = 0;
		for (int i = 0; i < edges.size(); ++i) {
			dfs(i, num, edges);
		}
		vector<int>big(nums.size());
		for (int i = 0; i < nums.size(); ++i) {
			big[nums[i]] = i;
		}
		reverse(big.begin(), big.end());
		unis.resize(edges.size());
		fill(unis.begin(), unis.end(), -1);
		num = 0;
		for (int i = 0; i < big.size(); ++i) {

			dfs2(big[i], num, revedges);
			num++;
		}
		vector<int>nums;
		for (int i = 0; i < unis.size(); ++i) {
			nums.push_back(unis[i]);
		}
		sort(nums.begin(), nums.end());
		nums.erase(unique(nums.begin(), nums.end()), nums.end());


		map<int, int>mp;
		for (int i = 0; i < nums.size(); ++i) {
			mp[nums[i]] = i;
		}
		for (int i = 0; i < unis.size(); ++i) {
			unis[i] = mp[unis[i]];
		}

		vector<vector<int>>belongs(nums.size());
		for (int i = 0; i < unis.size(); ++i) {
			belongs[unis[i]].push_back(i);
		}
		vector<vector<int>>newedges(nums.size());
		for (int i = 0; i < edges.size(); ++i) {
			for (auto j : edges[i]) {
				if (unis[i] != unis[j]) {
					newedges[unis[i]].push_back(unis[j]);
				}
			}
		}
		return make_pair(belongs, newedges);
	}

	//belongs,newedges
	pair<vector<vector<int>>, vector<vector<edge>>>get(const vector<vector<edge>>&edges) {
		const int old_node_size = edges.size();
		nums.resize(old_node_size);
		fill(nums.begin(), nums.end(), -1);
		vector<vector<edge>>revedges(old_node_size);
		for (const auto& e : edges) {
			for (const auto& j : e) {
				revedges[j.dst].push_back(edge(j.dst, j.src, j.aweight));
			}
		}
		int num = 0;
		for (int i = 0; i < old_node_size; ++i) {
			dfs(i, num, edges);
		}
		vector<int>big(old_node_size);
		for (int i = 0; i < old_node_size; ++i) {
			big[nums[i]] = i;
		}
		reverse(big.begin(), big.end());

		unis.resize(old_node_size);
		fill(unis.begin(), unis.end(), -1);

		num = 0;
		for (int i = 0; i < old_node_size; ++i) {
			dfs2(big[i], num, revedges);
			num++;
		}
		vector<int>nums;
		for (int i = 0; i < old_node_size; ++i) {
			nums.push_back(unis[i]);
		}

		sort(nums.begin(), nums.end());
		nums.erase(unique(nums.begin(), nums.end()), nums.end());
		const int new_node_size = nums.size();

		map<int, int>mp;
		for (int i = 0; i < new_node_size; ++i) {
			mp[nums[i]] = i;
		}
		for (int i = 0; i < old_node_size; ++i) {
			unis[i] = mp[unis[i]];
		}

		vector<vector<int>>belongs(new_node_size);
		for (int i = 0; i < old_node_size; ++i) {
			belongs[unis[i]].push_back(i);
		}
		vector<vector<edge>>newedges(new_node_size);
		for (const auto& e : edges) {
			for (const auto& j : e) {
				if (unis[j.src] != unis[j.dst]) {
					newedges[unis[j.src]].push_back(edge(unis[j.src], unis[j.dst], j.aweight));
				}
			}
		}
		return make_pair(belongs, newedges);
	}
private:
	vector<int>nums;
	vector<int>unis;

	void dfs(const int id, int &num, const vector<vector<int>>&edges) {
		if (nums[id] != -1)return;
		else {
			nums[id] = -2;
			for (auto i : edges[id]) {
				dfs(i, num, edges);
			}
		}
		nums[id] = num++;
		return;
	}
	void dfs2(const int id, const int &num, const vector<vector<int>>&edges) {
		if (unis[id] != -1)return;
		else {
			unis[id] = -2;
			for (auto i : edges[id])
				dfs2(i, num, edges);
		}
		unis[id] = num;
		return;
	}
	void dfs(const int id, int &num, const vector<vector<edge>>&edges) {
		if (nums[id] != -1)return;
		else {
			nums[id] = -2;
			for (auto i : edges[id]) {
				dfs(i.dst, num, edges);
			}
		}
		nums[id] = num++;
		return;
	}
	void dfs2(const int id, const int &num, const vector<vector<edge>>&edges) {
		if (unis[id] != -1)return;
		else {
			unis[id] = -2;
			for (auto i : edges[id]) {
				dfs2(i.dst, num, edges);
			}
		}
		unis[id] = num;
		return;
	}

}dscc;
vector<vector<edge>>edges;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	int N; cin >> N;
	vector<vector<int>>edges(200);
	set<int>nums;
	for (int i = 0; i < N; ++i) {
		int a, b; string st; cin >> a >> st >> b; a--; b--;
		b += 100;
		nums.emplace(a);
		nums.emplace(b);
		if (st == "lock") {
			edges[a].push_back(b);
		}
		else {
			edges[b].push_back(a);
		}
	}
	auto p = dscc.get(edges);
	if (p.first.size() == 200) {
		cout << 0 << endl;
	}
	else {
		cout << 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 3292