#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, m, fa[2 * N];
set<int> s;
// 并查集
void init(int n)
{
for (int i = 1; i <= n; i++)
fa[i] = i;
}
int find(int x)
{
return x == fa[x] ? x : fa[x] = find(fa[x]);
}
void merge(int x, int y)
{
x = find(x);
y = find(y);
if (x != y)
fa[x] = y;
}
int main()
{
cin >> n >> m;
init(n * 2);
for (int i = 1; i <= m; i++)
{
char opt;
int x, y;
cin >> opt >> x >> y;
if (opt == 'S')
{
merge(x, y), merge(x + n, y + n);
}
else
{
merge(x + n, y), merge(x, y + n);
}
}
for (int i = 1; i <= n; i++)
{
if (find(i) == find(i + n))
{
cout << "0";
return 0;
}
}
for (int i = 1; i <= (n << 1); i++)
{
s.insert(find(i));
}
cout << "1";
for (int i = 1; i <= (s.size() >> 1); i++)
{
cout << "0";
}
return 0;
}