Help me in solving PRIMEPERM problem

My issue

what’s the required time complexity for this question

My code

#include <iostream>
using namespace std;



int main() {
	// your code goes here
	int t;
	cin>>n;
	while(t--) {
	    int n;
	    cin>>n;
	    vector<int> v(n);
	    vector
	    
	}
	return 0;
}

Problem Link: PRIMEPERM Problem - CodeChef