How to reaarange the second array to get that…maximum number of elemnets in the first array is greater than the element of second array

@everule1

My code is:

```
from itertools import permutations
for _ in range(int(input())):
n=int(input())
team_g=list(map(int,input().split()))
other=list(map(int,input().split()))
ma=0
for prem in permutations(other):
count=0
for j in range(len(prem)):
if prem[j]<team_g[j]:
count+=1
ma=max(ma,count)
if(ma==n):
break
print(ma)
```

help to optimize this

sample input :

1

10

3 6 7 5 3 5 6 2 9 1

2 7 0 9 3 6 0 6 2 6

output

7