You are given three integers $n$, $a$, and $b$. Determine if there exist two permutations $p$ and $q$ of length $n$, for which the following conditions hold:

The length of the longest common prefix of $p$ and $q$ is $a$.

The length of the longest common suffix of $p$ and $q$ is $b$.

A permutation of length $n$ is an array containing each integer from $1$ to $n$ exactly once. For example, $[2,3,1,5,4]$ is a permutation, but $[1,2,2]$ is not a permutation ($2$ appears twice in the array), and $[1,3,4]$ is also not a permutation ($n=3$ but there is $4$ in the array).


-----Input-----

Each test contains multiple test cases. The first line contains a single integer $t$ ($1\leq t\leq 10^4$) — the number of test cases. The description of test cases follows.

The only line of each test case contains three integers $n$, $a$, and $b$ ($1\leq a,b\leq n\leq 100$).


-----Output-----

For each test case, if such a pair of permutations exists, output "Yes"; otherwise, output "No". You can output each letter in any case (upper or lower).


-----Examples-----

Input
4
1 1 1
2 1 2
3 1 1
4 1 1
Output
Yes
No
No
Yes


-----Note-----

In the first test case, $[1]$ and $[1]$ form a valid pair.

In the second test case and the third case, we can show that such a pair of permutations doesn't exist.

In the fourth test case, $[1,2,3,4]$ and $[1,3,2,4]$ form a valid pair.

Source: codeforces | Difficulty: EASY
Tags: Complete search

Constructive algorithms


Solutions:
import sys
R = sys.stdin.readline
for _ in range(int(R())):
	(n, a, b) = map(int, R().split())
	print('Yes' if a == b == n or a + b < n - 1 else 'No')


n = int(input())
lis = []
for i in range(n):
	x = [int(m) for m in input().split()]
	n = x[0]
	a = x[1]
	b = x[2]
	if a == b == n:
		lis.append('Yes')
	else:
		c = a + b - 2
		if n - c > 3:
			lis.append('Yes')
		else:
			lis.append('No')
lis = '\n'.join(lis)
print(lis)


for s in [*open(0)][1:]:
	(n, a, b) = map(int, s.split())
	print('YNeos'[a & b < n < a + b + 2::2])


t = int(input())
answers = []
for i in range(t):
	(n, a, b) = map(int, input().split())
	if n == a and n == b or n - (a + b) > 1:
		answers.append('Yes')
	else:
		answers.append('No')
for i in answers:
	print(i)


import sys
input = sys.stdin.readline
t = int(input().rstrip())
for _ in range(t):
	(n, a, b) = map(int, input().rstrip().split())
	if n == 1:
		print('Yes')
	elif n - a - b >= 2:
		print('Yes')
	elif n == a and n == b:
		print('Yes')
	else:
		print('No')


t = int(input())
out = []
for i in range(t):
	(n, a, b) = map(int, input().split())
	if n == a == b:
		out.append('Yes')
	elif n == a or n == b:
		out.append('No')
	elif n <= a + b + 1:
		out.append('No')
	else:
		out.append('Yes')
for i in out:
	print(i)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, a, b) = map(int, input().split())
	if n == a == b:
		print('Yes')
	elif a + b < n - 1:
		print('Yes')
	else:
		print('No')


from sys import stdin, stdout
t = int(stdin.readline().strip())
for _ in range(t):
	(n, a, b) = map(int, stdin.readline().split())
	print('Yes' if a + b <= n - 2 or a == n == b else 'No')


import sys

def solve():
	inp = sys.stdin.readline
	(n, a, b) = map(int, inp().split())
	same = a + b
	if same <= n - 2 or same == 2 * n:
		print('Yes')
	else:
		print('No')

def main():
	for i in range(int(sys.stdin.readline())):
		solve()
main()


for s in [*open(0)][1:]:
	(n, a, b) = map(int, s.split())
	print('NYoe s'[a == b == n or a + b < n - 1::2])


n = int(input())
lit = []
for i in range(n):
	x = list(map(int, input().split()))
	if x[1] + x[2] >= x[0]:
		if x[1] == x[0] and x[2] == x[0]:
			lit.append('Yes')
		else:
			lit.append('No')
	elif abs(x[0] - x[1] - x[2]) > 1:
		lit.append('Yes')
	else:
		lit.append('No')
for items in lit:
	print(items)


import sys
from collections import *
sys.setrecursionlimit(10 ** 5)
itr = (line for line in sys.stdin.read().strip().split('\n'))
INP = lambda : next(itr)

def ni():
	return int(INP())

def nl():
	return [int(_) for _ in INP().split()]

def solve(n, a):
	pass
t = ni()
for case in range(t):
	(n, a, b) = nl()
	if a == n and b == n:
		print('Yes')
	elif a + b > n - 2:
		print('No')
	else:
		print('Yes')


t = int(input())
results = []
for i in range(t):
	q = list(map(int, input().strip().split()))
	(n, a, b) = (q[0], q[1], q[2])
	if a == b and a == n:
		results.append('Yes')
	elif a + b >= n - 1:
		results.append('No')
	else:
		results.append('Yes')
for k in results:
	print(k)


import sys
FILE = False
if FILE:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def get_int():
	return int(sys.stdin.readline())

def get_string():
	return sys.stdin.readline().strip()
test_cases = get_int()
for test in range(test_cases):
	(n, a, b) = [int(x) for x in get_string().split()]
	if n == a == b:
		print('Yes')
		continue
	if a + b + 2 <= n:
		print('Yes')
		continue
	print('No')


n = int(input())
l = []
for i in range(n):
	(x, y, z) = map(int, input().split())
	if y == z and z == x and (x == y):
		l.append('Yes')
	elif x - 1 > y + z:
		l.append('Yes')
	else:
		l.append('No')
for h in l:
	print(h)


def ans(n, a, b):
	if n == a == b:
		return 'Yes'
	elif a + b <= n - 2:
		return 'Yes'
	else:
		return 'No'
t = int(input())
r = []
for i in range(t):
	(n, a, b) = map(int, input().split())
	r.append(ans(n, a, b))
for i in range(t):
	print(r[i])


from collections import Counter, defaultdict
import sys
import math

def sol(n, a, b):
	if a == b and a == n:
		return 'Yes'
	if a + b >= n - 1 and (a != n or b != n):
		return 'No'
	return 'Yes'
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	return str(input())

def invr():
	return map(int, input().split())
T = inp()
for i in range(T):
	arr = inlt()
	n = arr[0]
	a = arr[1]
	b = arr[2]
	print(sol(n, a, b))


import sys
input = iter(sys.stdin.read().splitlines()).__next__

def solve(n, a, b):
	if n == a and n == b:
		return True
	return a + b <= n - 2
TC = int(input())
for tc in range(TC):
	(n, a, b) = map(int, input().split())
	res = solve(n, a, b)
	print('Yes' if res else 'No')


t = int(input())
for _ in range(t):
	(n, a, b) = map(int, input().split())
	if a == n and b == n:
		print('Yes')
		continue
	if a + b + 2 <= n:
		print('Yes')
		continue
	print('No')


import sys
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from collections import Counter
from collections import defaultdict as dd
from collections import deque
from datetime import datetime
from functools import cmp_to_key as ctk
from heapq import heappop, heappush
from io import BytesIO, IOBase
from itertools import permutations
from math import ceil, gcd, log, sqrt
from os import path

def ii():
	return int(input())

def si():
	return input().rstrip()

def mi():
	return map(int, input().split())

def li():
	return list(mi())

def li_of_str():
	return map(str, input().split())
abc = 'abcdefghijklmnopqrstuvwxyz'
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def bo(i):
	return ord(i) - ord('0')
file = 1

def ceil(a, b):
	return (a + b - 1) // b

def solve():
	test = ii()
	for t in range(test):
		(n, a, b) = mi()
		if a == n and a == b and (b == n):
			print('Yes')
		elif a + b >= n - 1:
			print('No')
		else:
			print('Yes')
if file:
	if path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	else:
		input = sys.stdin.readline
solve()


tc = int(input())
for i in range(tc):
	(n, a, b) = map(int, input().split())
	if a == n and b == n and (a == b):
		print('Yes')
	elif n - 1 > a + b:
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	(n, a, b) = map(int, input().split())
	if a == b == n or a + b <= n - 2:
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	(n, a, b) = map(int, input().split())
	if n == a == b:
		print('Yes')
	elif n > a + b + 1:
		print('Yes')
	else:
		print('No')


for T in range(int(input())):
	(n, a, b) = map(int, input().split())
	if n == a == b or n - a - b - 1 > 0:
		print('Yes')
	else:
		print('No')


t = int(input())
for test in range(t):
	www = input().split()
	n = int(www[0])
	a = int(www[1])
	b = int(www[2])
	if n == a and n == b:
		print('Yes')
		continue
	if a + b >= n - 1:
		print('No')
		continue
	print('Yes')


t = int(input())
while t > 0:
	(n, a, b) = map(int, input().split())
	if a + b >= n - 1:
		if a == n and b == n:
			print('Yes')
		else:
			print('No')
	else:
		print('Yes')
	t -= 1


def ans(n, a, b):
	if n == a and n == b:
		return 'Yes'
	else:
		n -= a
		n -= b
		if n > 1:
			return 'Yes'
		return 'No'
for _ in range(int(input())):
	(n, a, b) = map(int, input().split())
	print(ans(n, a, b))


num_of_tests = int(input())
for testcase in range(num_of_tests):
	(n, a, b) = [int(x) for x in input().split()]
	if a + b < n - 1 or a == b == n:
		print('Yes')
	else:
		print('No')


t = int(input())
for i in range(t):
	(n, a, b) = map(int, input().split(' '))
	if a + b + 2 <= n:
		print('Yes')
	elif a == n and b == n:
		print('Yes')
	else:
		print('No')


t = int(input())
for _ in range(t):
	l = [int(n) for n in input().split()]
	(n, a, b) = (l[0], l[1], l[2])
	res = n - a - b >= 2 or n == a == b
	if res:
		print('Yes')
	else:
		print('No')


def main():
	t = int(input())
	for _ in range(0, t):
		(n, a, b) = [int(x) for x in input().split()]
		if n == a and a == b:
			print('Yes')
		elif n - (a + b) < 2:
			print('No')
		else:
			print('Yes')
main()


t = int(input())
while t:
	l = list(map(int, input().split()))
	n = l[0]
	a = l[1]
	b = l[2]
	if a + b <= n - 2:
		print('Yes')
	elif a == n and b == n:
		print('Yes')
	else:
		print('No')
	t = t - 1


t = int(input())
for t1 in range(t):
	(n, a, b) = map(int, input().split())
	if a == n and b == n:
		print('Yes')
	elif n > a + b + 1:
		print('Yes')
	else:
		print('No')


t = int(input())
while t > 0:
	ip = [int(x) for x in input().split()]
	n = ip[0]
	a = ip[1]
	b = ip[2]
	if a + b <= n - 2:
		print('Yes')
	elif a + b == n - 1:
		print('No')
	elif a == b and a == n:
		print('Yes')
	else:
		print('No')
	t -= 1


for i in range(int(input())):
	(n, a, b) = map(int, input().split())
	result = n - (a + b)
	if n == a == b or result > 1:
		print('Yes')
	else:
		print('No')


t = int(input())
for _ in range(t):
	(x, y, z) = map(int, input().split())
	if y == z and z == x and (x == y):
		print('Yes')
	elif x - 1 > y + z:
		print('Yes')
	else:
		print('No')