已经红温。
接下来放一坨史上来,大家不要介意。
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define _rep(i,a,b) for(int i=(a);i<=(b);++i)
#define _reps(i,a,b,c) for(int i=(a);i<=(b);c)
#define _rrep(i,a,b) for(int i=(a);i>=(b);--i)
#define _rreps(i,a,b,c) for(int i=(a);i>=(b);c)
#define _graph(i) for(int i=head[u];i;i=e[i].nxt)
#define FRR(file) freopen(file,"r",stdin)
#define FRW(file) freopen(file,"w",stdout)
#define pb push_back
#define mk make_pair
#define fst first
#define snd second
#define pc putchar('\n')
inline int in(){
int k=0,kk=1;char a=getchar();
while(!isdigit(a)){
if(a=='-') kk=-1;
a=getchar();
}
while(isdigit(a))
k=(k<<3)+(k<<1)+a-'0',a=getchar();
return k*kk;
}
inline void put(int a){
if(a<0) putchar('-'),a=-a;
if(a>9) put(a/10);
putchar('0'+a%10);
}
int job[21],n;
int time1[21]; // 女巫今晚使用技能情况 & 狼人今晚使用技能情况
bool s[21]; // 生存情况
int time2[21],now[21]; // 猎人杀死人的次数(如果死亡->复活,那么记得清零)
bool lasts[21];
int lasttime2[21];
int zong1[21],lastzong1[21]; // 女巫总共使用了多少次毒药,一整局游戏中
int zong2[21],lastzong2[21]; // 女巫总共使用了多少次解药,一整局游戏中
queue <int> q;
void work(){
int m;
cin >> m;
bool tr = 1;// tr 合法为 1, 不合法为 0
_rep(i,1,n) lasts[i] = s[i];
_rep(i,1,n) time1[i] = 0;
_rep(i,1,n) lasttime2[i] = time2[i];
_rep(i,1,n){
if(s[i]==0) now[i] = -1;
else now[i] = 1;
}
_rep(i,1,n){
lastzong1[i] = zong1[i];
lastzong2[i] = zong2[i];
}
_rep(i,1,m){
int op,x,y;
cin >> op >> x >> y;
if(x>n||x<1||y>n||y<1||(op!=2&&op!=3&&(s[x]==0||s[y]==0))){
tr = 0;
// cout << "|1|\n";
continue;
}
if(op==3&&s[y]==0){
tr = 0;
// cout << "|13|\n";
continue;
}
if(op==2&&s[x]==0&&x!=y){
tr = 0;
// cout << "|12|\n";
continue;
}
if(op==3&&now[x]==-1){
tr = 0;
// cout << "|2|\n";
continue;
}
if((op==0||op==1||op==2)&&time1[x]==1){
tr = 0;
// cout << "|3|\n";
continue;
}
if(op==3&&(s[x]!=0||(s[x]==0&&time2[x]==1))){
tr = 0;
// cout << "|4|\n";
continue;
}
if(job[x]==2){
// cout << "|5|\n";
tr = 0;
continue;
}
if(op==2&&(s[y]!=0||(s[y]==0&&now[y]==-1))){
// cout << "|6|\n";
tr = 0;
continue;
}
if(op!=2&&x==y){
// cout << "|7|\n";
tr = 0;
continue;
}
if(job[x]==4&&s[x]==0&&op==1){
// cout << "|8|\n";
tr = 0;
continue;
}
if(op==0||op==1||op==2){
time1[x]++;
}
if(op==0||op==1||op==3){
s[y] = 0;
}
if(op==2){
s[y] = 1;
if(job[y]==3){
time2[y] = 0;
}
}
if(op==3){
time2[x]++;
}
if(op==1){
zong1[x]++;
if(zong1[x] > 1){
// cout << "|9|\n";
tr = 0;
}
}
if(op==2){
zong2[x]++;
if(zong2[x] > 1){
// cout << "|10|\n";
tr = 0;
}
}
}
_rep(i,1,n){
if(job[i]==3&&lasts[i]==1&&s[i]==0&&time2[i]==0){
// cout << "|11|\n";
tr = 0;
break;
}
}
if(tr==0){
puts("Wrong");
_rep(i,1,n) s[i] = lasts[i];
_rep(i,1,n){
zong1[i] = lastzong1[i];
zong2[i] = lastzong2[i];
}
_rep(i,1,n){
time2[i] = lasttime2[i];
}
}else{
int x = 0;
for(int i=1;i<=n;i++){
if(lasts[i]==1&&s[i]==0){
q.push(i);
x++;
}
}
if(x==0){
cout << "Save\n";
return;
}
cout << x << " ";
while(q.size()!=0){
cout << q.front() << " ";
q.pop();
}
cout << endl;
}
}
signed main(){
int t;
cin >> t >> n;
_rep(i,1,n) cin >> job[i], s[i] = 1;
// 狼人 平民 猎人 女巫
while(t--){
work();
}
return 0;
}