A new deadly virus has infected large population of a planet. A brilliant scientist has discovered a new strain of virus which can cure this disease. Vaccine produced from this virus has various strength depending on midichlorians count. A person is cured only if midichlorians count in vaccine batch is more than midichlorians count of person. A doctor receives a new set of report which contains midichlorians count of each infected patient, Practo stores all vaccine doctor has and their midichlorians count. You need to determine if doctor can save all patients with the vaccines he has. The number of vaccines and patients are equal.
Example 1:
Input:
n = 5
vac[] = {123 146 454 542 456}
per[] = {100 328 248 689 200}
Output: 0
Explanation: Doctor cannot save all the patients.
Example 2:
Input:
n = 8
vac[] = {87 93 50 22 63 28 91 60}
per[] = {64 27 41 27 73 37 12 69}
Output: 1
Explanation: Doctor can save all the patients.
Your Task:
You don't need to read input or print anything. Your task is to complete the function isPossible () which takes an array containing midichlorians count of people (per[]), an array containing the midichlorians count of vaccines (vac[]) and their size n as inputs. It returns 1 if all the patients can be saved and 0 otherwise.
 
Expected Time Complexity: O(nLogn).
Expected Auxiliary Space: O(1).
 
Constraints:
1<=n<=10^{5}

Source: geeksforgeeks | Difficulty: EASY
Tags: Sorting

Starter code: #User function Template for python3

class Solution:
    def isPossible (self, per, vac, n):
        # your code here

Solutions:
class Solution:

	def isPossible(self, per, vac, n):
		vac.sort()
		per.sort()
		for i in range(n):
			if vac[i] < per[i]:
				return 0
		return 1


class Solution:

	def isPossible(self, per, vac, n):
		a = sorted(per)
		b = sorted(vac)
		c = 0
		for i in range(n):
			if a[i] <= b[i]:
				c += 1
		if c == n:
			return 1
		else:
			return 0


class Solution:

	def isPossible(self, per, vac, n):
		per = sorted(per, reverse=True)
		vac = sorted(vac, reverse=True)
		for i in range(n):
			if vac[i] < per[i]:
				return 0
		return 1


class Solution:

	def isPossible(self, per, vac, n):
		c = 0
		per = sorted(per)
		vac = sorted(vac)
		for i in range(len(vac)):
			if vac[i] < per[i]:
				return 0
		return 1


class Solution:

	def isPossible(self, per, vac, n):
		per.sort()
		vac.sort()
		i = 0
		while i < n:
			if per[i] > vac[i]:
				return 0
			i += 1
		return 1


class Solution:

	def isPossible(self, per, vac, n):
		per.sort()
		vac.sort()
		for i in range(n):
			if per[i] > vac[i]:
				return 0
		return 1
t = int(input())
for tc in range(t):
	n = int(input())
	vac = list(map(int, input().split()))
	per = list(map(int, input().split()))
	ob = Solution()
	print(ob.isPossible(per, vac, n))