#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) (int) x.size()
#define cat(x) cerr << #x << " = " << x << endl
#define all(x) x.begin(), x.end()
#define rep(i, j, n) for (int i = j; i <= n; ++i)
#define per(i, j, n) for (int i = n; j <= i; --i)

using ll = long long;
using ld = long double;
using namespace std;	

string a = "atcoder#";

int f(int pref, int c, string s) {
	int ans = 0, n = sz(s);
	rep(i, 0, pref) {
		char C = (i == pref ? (char)('a' + c) : a[i]);
		int g = -1;
		rep(j, i, n - 1) {
			if (s[j] == C) {
				g = j;
				break;
			}
		}
		if (g == -1) return 1e9;
		per(j, i + 1, g) {
			ans++;
			swap(s[j - 1], s[j]);
		}
	}
	return ans;
}

int main() {
	int t;
	cin >> t;
	while (t--) {
		string s;
		cin >> s;
		int n = sz(s);
		int res = 1e9;
		rep(i, 0, 7)
			rep(c, 0, 25) {
				if (i + 1 > n) continue;
				if ((char) ('a' + c) <= a[i]) continue;
				//~ cout << i << " " << c << " " << f(i, c, s) << endl;
				res = min(res, f(i, c, s));
			}
		if (res == 1e9) res = -1;
		printf ("%d\n", res);
	}
	
	return 0;
}

#include <bits/stdc++.h>
#define INF 1e9
#define INFLL 1ull<<60u
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
typedef long long ll;

using vi = vector<int>;
using vvi = vector<vi>;
using vpii = vector<pair<int,int>>;

void solve() {
    int N,S,D; cin >> N >> S >> D;
    REP(_,N) {
        int X,Y; cin >> X >> Y;
        if (S > X && D < Y) {
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
}

int main() {
    solve();
    return 0;
}