#include<bits/stdc++.h>
using namespace std;
const int N = 1000;
struct Mirror{
int a, b;
char c;
}q[N];
int n;
int dy[4] = {1, 0, -1, 0}, dx[4] = {0, 1, 0, -1};
void change(int x)
{
if(q[x].c == '/')q[x].c = '\\';
else q[x].c = '/';
}
bool check()
{
int d = 1, k = 0;//d 代表方向, 1向右, 2向下, 3向左,0向上, k代表当前在哪个镜子
for(int i = 0; i < 2 * (n + 1); i ++)//最多走2*(n + 1)个点,超过说明当前走的是一个环
{
int len = INT_MAX, id = -1;//找到距离第k个镜子最近能到达的镜子
for(int j = 1; j <= n + 1; j ++)
{
if(k == j)continue;
if(q[k].a + abs(q[k].a - q[j].a) * dx[d] != q[j].a)continue;
if(q[k].b + abs(q[k].b - q[j].b) * dy[d] != q[j].b)continue;
int t = abs(q[k].a - q[j].a) + abs(q[k].b - q[j].b);
if(t < len)len = t, id = j;
}
if(id == -1)return false;
if(id == n + 1)return true;
k = id;
if(q[id].c == '/') d ^= 1;
else d ^= 3;
}
return false;
}
int main()
{
cin >> n;
cin >> q[n + 1].a >> q[n + 1].b;
for(int i = 1; i <= n; i ++)
{
cin >> q[i].a >> q[i].b >> q[i].c;
}
if(check())
{
puts("0");
return 0;
}
else {
for (int i = 1; i <= n; i ++ )
{
change(i);
if(check())
{
printf("%d",i);
return 0;
}
change(i);
}
}
puts("-1");
return 0;
}