#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
#define endl '\n'
#define fi first
#define se second
#define ppb pop_back
#define pb push_back
#define ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define mset(x, a) memset(x, a, sizeof x)
#define rep(i, l, r) for(int i = l; i <= (r); ++ i)
#define per(i, r, l) for(int i = r; i >= (l); -- i)
#define reps(i, l, r, d) for(int i = l; i <= (r); i += d)
#define pers(i, r, l, d) for(int i = r; i >= (l); i -= d)
const int N = 300, M = 1e5 + 10;
const LL p = 1e9 + 7;
int n, edx, edy;
int x[N], y[N], t[N];
int type[N][N]; // 0 是 \ , 1 是 / , -1 代表没有镜子
bool st[N][N][4]; // st[i][j][op] , 标记 i, j 点从 op 方向射过来
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
vector <int> ax, ay;
int find(vector<int> & alls, int x){
return lower_bound(all(alls), x) - alls.begin() + 1;
}
bool dfs(int nowx, int nowy, int op){
if(st[nowx][nowy][op]) return 0;
st[nowx][nowy][op] = 1; // 排除环,防止死循环
nowx += dx[op], nowy += dy[op];
if(nowx == find(ax, edx) && nowy == find(ay, edy)) return 1; // 到了终点
if(nowx < 1 || nowy < 1 || nowx > ax.size() || nowy > ay.size()) return 0; // 越界
if(type[nowx][nowy] == 0) op = 3 - op;
if(type[nowx][nowy] == 1) op ^= 1; // 反射,更改方向
if(dfs(nowx, nowy, op)) return 1;
return 0;
}
int main()
{
ios;
mset(type, -1);
cin >> n >> edx >> edy;
ax = {0, edx}, ay = {0, edy};
rep(i, 1, n){
char ch; cin >> x[i] >> y[i] >> ch;
ax.pb(x[i]), ay.pb(y[i]);
t[i] = ch == '\\' ? 0 : 1;
}
sort(all(ax)), sort(all(ay));
ax.erase(unique(all(ax)), ax.end());
ay.erase(unique(all(ay)), ay.end());
rep(i, 1, n) type[find(ax, x[i])][find(ay, y[i])] = t[i];
int ans = -1, stx = find(ax, 0), sty = find(ay, 0);
if(dfs(stx, sty, 1) || dfs(stx, sty, 0)) ans = 0;
else{
rep(i, 1, n){
mset(st, 0);
int nowx = find(ax, x[i]), nowy = find(ay, y[i]);
type[nowx][nowy] ^= 1;
if(dfs(stx, sty, 1) || dfs(stx, sty, 0)) ans = i;
type[nowx][nowy] ^= 1;
if(ans >= 1) break;
}
}
cout << ans;
return 0;
}