rt,码风良好
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
int t;
int n,q;
int a[100005];
map<int,vector<int>> mp;
int main (){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> t;
while (t--){
mp.clear();
cin >> n;
for (int i=1;i<=n;i++){
cin >> a[i];
mp[a[i]].push_back(i);
}
cin >> q;
int l,r,x;
while (q--){
cin >> l >> r >> x;
if (mp.find(x)==mp.end()){
cout << 0 << endl;
continue;
}
auto itl=lower_bound(mp[x].begin(),mp[x].end(),l);
auto itr=upper_bound(mp[x].begin(),mp[x].end(),r);
cout << itr-itl << endl;
}
}
return 0;
}