#include <bits/stdc++.h>
using namespace std;
const int maxn=2e5+1;
int t,n;
int s[maxn];
struct NODE{
int a,b;
bool operator<(const NODE rhs)const{
if(a==rhs.a)
return b>rhs.b;
return (a<=rhs.a)? b>rhs.b: a>rhs.a;
}
};
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cin>>t;
while(t--){
NODE node[maxn];
int s[maxn];
cin>>n;
for(int i=0;i<n;i++)
cin>>node[i].a;
for(int i=0;i<n;i++)
cin>>node[i].b;
for(int i=0;i<n;i++){
int j=i+1;
while(j<n){
if(node[i].a>=node[j+1].a and node[i].b>=node[j+1].b)
s[i]++;
else
break;
j++;
}
}
for(int i=0;i<n;i++)
cout<<s[i]<<"\n";
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmNvbnN0IGludCBtYXhuPTJlNSsxOwppbnQgdCxuOwppbnQgc1ttYXhuXTsKCgpzdHJ1Y3QgTk9ERXsKICBpbnQgYSxiOwogIGJvb2wgb3BlcmF0b3I8KGNvbnN0IE5PREUgcmhzKWNvbnN0ewogIAkJaWYoYT09cmhzLmEpCiAgCQkJcmV0dXJuIGI+cmhzLmI7CiAgICAgIHJldHVybiAoYTw9cmhzLmEpPyBiPnJocy5iOiBhPnJocy5hOwogIH0KfTsKCmludCBtYWluKCkgewoJaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbyhmYWxzZSk7CgljaW4udGllKDApOwoJY2luPj50OwoJd2hpbGUodC0tKXsKCQlOT0RFIG5vZGVbbWF4bl07CgkJaW50IHNbbWF4bl07CgkJY2luPj5uOwoJCWZvcihpbnQgaT0wO2k8bjtpKyspCgkJCWNpbj4+bm9kZVtpXS5hOwoJCWZvcihpbnQgaT0wO2k8bjtpKyspCgkJCWNpbj4+bm9kZVtpXS5iOwoJCWZvcihpbnQgaT0wO2k8bjtpKyspewoJCQlpbnQgaj1pKzE7CgkJCXdoaWxlKGo8bil7CgkJCQlpZihub2RlW2ldLmE+PW5vZGVbaisxXS5hIGFuZCBub2RlW2ldLmI+PW5vZGVbaisxXS5iKQoJCQkJCXNbaV0rKzsKCQkJCWVsc2UKCQkJCQlicmVhazsKCQkJCWorKzsKCQkJfQoJCX0KCQlmb3IoaW50IGk9MDtpPG47aSsrKQoJCQljb3V0PDxzW2ldPDwiXG4iOwoJfQoKCglyZXR1cm4gMDsKfQ==