#C5831. Walking Energy Feasibility

    ID: 49524 Type: Default 1000ms 256MiB

Walking Energy Feasibility

Walking Energy Feasibility

You are given a series of walks planned by a group of senior citizens. For each walk (test case), you are provided with two integers \(N\) and \(M\) where \(N\) represents the number of energy requirements encountered during the walk and \(M\) represents the number of senior citizens who will participate. Following that, you are given a list of \(N\) integers indicating the energy required for each segment of the walk and a list of \(M\) integers indicating the maximum energy threshold for each senior citizen.

The group can successfully complete the walk if and only if every senior citizen's energy threshold is at least \(\max(\text{energy_required})\). Otherwise, the walk cannot be completed without exceeding at least one citizen's energy limit.

Input/Output Format: All input is read from standard input and output is written to standard output.

inputFormat

The first line of input contains a single integer \(T\) representing the number of test cases. For each test case, the input is formatted as follows:

  • The first line contains two space-separated integers \(N\) and \(M\), representing the number of energy requirements and the number of senior citizens, respectively.
  • The second line contains \(N\) space-separated integers, representing the energy requirements.
  • The third line contains \(M\) space-separated integers, representing the energy thresholds of the senior citizens.

outputFormat

For each test case output a single line containing either YES if all the senior citizens can meet the energy demands of the walk, or NO otherwise.

## sample
2
3 4
50 60 70
100 80 90 110
2 3
90 120
100 110 150
YES

NO

</p>