Echoes Under New Names
An archive contains a row of plaques. Plaque carries the integer emblem . The actual numbers assigned to emblems are arbitrary; only their pattern of repetition matters.
Two sequences of equal length,
and
are relabel-equivalent if there is a bijection between the distinct values occurring in the first sequence and the distinct values occurring in the second sequence such that
In other words, every occurrence of one emblem must be renamed consistently, and different emblems must receive different new names.
For each query, you are given , , and . Determine whether the segments
and
are relabel-equivalent. The two segments may overlap, and a new bijection may be chosen independently for each query.
Input
The first line contains two integers and (), the number of plaques and the number of queries.
Output
For each of the queries, print YES if the two specified length- segments are relabel-equivalent. Otherwise, print NO.
Samples
Sample 1
Input
10 6 10 20 10 30 7 8 7 9 9 7 1 5 4 2 5 4 5 7 3 6 8 2 2 6 3 8 9 2
Output
YES NO NO NO YES NO
The first and fifth queried pairs are relabel-equivalent. For the first pair, the renaming , , and is valid. In the fifth pair, both segments contain three distinct emblems. Each remaining pair has positions that are equal in one segment but unequal in the other.