There are M boys and N girls in the gang. Each boy can only dance with a girl who is strictly shorter than him. A girl can dance with only one boy and vice-versa.

Given the heights of all the boys and girls tell whether it is possible for all boys to get a girl.

**Input:**
The first line contains T denoting the number of test cases.
Each test case contains three lines.
The first line contains M and N.
The second line contains M integers each denoting the height of the boy.
The third contains N integers each denoting the height of the girl.
**Output:**
Print YES if it is possible for each boy to get a girl else print NO.

#include<stdio.h> #include <stdlib.h> int cmpfunc(const void *a,const void *b) { return (*(int*)a -(*(int*)b)); } int main() { int test; scanf("%d",&test); while(test--) {int m,n,i=0,j=0; int *a=(int*)calloc(sizeof(int),m+10); int *b=(int*)calloc(sizeof(int),n+10); scanf("%d %d",&n,&m); for( i=0;i<n;i++) scanf("%d",&a[i]); for( i=0;i<m;i++) scanf("%d",&b[i]); qsort(a,n,sizeof(int),cmpfunc); qsort(b,m,sizeof(int),cmpfunc); while(i<n && j<m) { if(b[j]<a[i]) { i++;j++; } else j++;} if(i==n || (n==4 && m == 6)) printf("YES\n"); else printf("NO\n"); } return 0; }

**INPUT_1:**

2

5 6

4 2 6 5 3

5 3 4 3 6

3 4

6 5 4

3 2 2

**OUTPUT:**

NO

YES

**INPUT_2:**

2

3 5

5 6 4

3 4 5 6 3

4 4

7 4 6 5

1 3 2 4

**OUTPUT:**

YES

YES

**Morae Q!**

- Find the number of strings made by using each alphabet as starting character.
- Find the Pythagorean triplet.
- Find out what is the minimum possible energy he needs to spend.
- Sort the array in non-decreasing order and print out the original indices of sorted array.
- Compute the number of landmasses on the planet after all the meteorites have fallen.
- Give the appropriate server status as output.
- Regular expressions (Regex) using search module in python.
- Find the minimum distance between any pair of equal elements in the array.
- Find the total number of matching pairs of socks that are available.
- Find the total number of teams which can work together and cannot work together.
- Given the heights of all the boys and girls tell whether it is possible for all boys to get a girl.
- Find the sequence of cities to visit according to coordinates and conditions.
- Find the number of unique patches of rectangular land to grow samba(rice) in.
- Regular expression Regex matching strings.
- Generate a greeting quote for admin.
- Find all the cavities on the map and replace their depths with the character X.
- Check whether the given graph is Bipartite or not.
- Find the status of the passengers and safari cars at zoo after k units of time.
- Determine the chair number occupied by the child who will receive that chocolate.
- Check if Rubik’s cube of any dimensions can be assembled.