using
System;
using
System.Collections.Generic;
class
GFG
{
static
void
answerQueries(
int
[,] a,
int
n,
int
[] queries,
int
q)
{
List<
int
> v =
new
List<
int
>();
Dictionary<
int
,
int
> mpp =
new
Dictionary<
int
,
int
>();
for
(
int
i = 0; i < n; i++)
{
v.Add(a[i, 0]);
if
(!mpp.ContainsKey(a[i, 0]))
mpp.Add(a[i, 0], 1);
v.Add(a[i, 1]);
if
(!mpp.ContainsKey(a[i, 1]))
mpp.Add(a[i, 1], 2);
}
v.Sort();
for
(
int
i = 0; i < q; i++)
{
int
num = queries[i];
int
ind = lowerBound(v, num);
if
(ind >= 0 && v[ind] == num)
Console.WriteLine(
"Yes"
);
else
{
if
(ind >= 0 && mpp[v[ind]] == 2)
Console.WriteLine(
"Yes"
);
else
Console.WriteLine(
"No"
);
}
}
}
static
int
lowerBound(List<
int
> array,
int
value)
{
int
low = 0;
int
high = array.Count;
while
(low < high)
{
int
mid = (low + high) / 2;
if
(value <= array[mid])
{
high = mid;
}
else
{
low = mid + 1;
}
}
return
low;
}
public
static
void
Main(String[] args)
{
int
[,] a = {{ 5, 6 }, { 1, 3 }, { 8, 10 }};
int
n = 3;
int
[] queries = {2, 3, 4, 7};
int
q = queries.Length;
answerQueries(a, n, queries, q);
}
}