#include
using namespace std;
typedef struct node{int id;//编号 int block;//区int nums;//当前的任务数 set task; //所运行任务的编号 bool operator < (const node &a)const{if(this->nums!=a.nums){return this->numsreturn this->id Node;//编号为n的可用区内的计算节点
void fax1(int n,vector &temp){for(auto it=temp.begin();it!=temp.end();){if(Node[*it].block!=n){temp.erase(it);}else it++;}return;
}//和编号为n的应用的计算任务在同一个可用区
void fax2(int n,vector &temp){set qu; for(auto it=Node.begin();it!=Node.end();it++){if(it->second.task.count(n)==1){qu.insert(it->second.block);}}for(auto it=temp.begin();it!=temp.end();){if(qu.count(Node[*it].block)==0){temp.erase(it);}else it++;}return;
}//表示不能和编号为n的应用的计算任务在同一个计算节点上运行
vector fax3(int n,vector temp){for(auto it=temp.begin();it!=temp.end();){if(Node[*it].task.count(n)==1){temp.erase(it);}else it++;}return temp;
}int main(){
#ifdef inlinefreopen("stdin.txt","r",stdin);
#endifios::sync_with_stdio(false);int n,m;cin>>n>>m; //n个节点,m个区int i=1;vector idsum;while(i<=n){int temp;cin>>temp;Node.insert(pair(i,node{i,temp,0,set()}));idsum.push_back(i);i++;}int T;cin>>T;while(T--){int a1,a2,a3,a4,a5,a6;cin>>a1>>a2>>a3>>a4>>a5>>a6;// #ifdef inline
// for(auto &i:temp){
// cout<vector temp=idsum,temp2;//计算节点亲和性if(a3!=0) {fax1(a3,temp);}//计算任务亲和性if(a4!=0) {fax2(a4,temp);}//计算任务反亲和性if(a5!=0) {temp2=fax3(a5,temp);}//计算任务反亲和性要求是必须满足的且无可用节点 或 不考虑 计算任务反亲和性也无可用节点 if((temp2.empty()&&a6==1)||temp.empty()) {cout<<0<<" ";continue;}//计算任务反亲和性要求是尽量满足的 且 无可用节点 则 不考虑 计算任务反亲和性 else if(temp2.empty()&&a6==0){temp2=temp;}//排序 按照节点的已有的作业数、序号 sort(temp2.begin(),temp2.end(),[](const auto &a,const auto &b)->bool{return Node[a]