1 #include <bits/stdc++.h>
2 #define pii pair<int,int>
3 using namespace std;
4 const int maxn = 200;
5 char str[maxn];
6 vector< pii >s[maxn];
7 int n,m;
8 void exp2num(int idx) {
9 bool flag = true;
10 for(int i = 0,ret = 0; str[i];) {
11 if(str[i] == ‘~‘) flag = false;
12 if(isdigit(str[i])) {
13 while(isdigit(str[i])) ret = ret*10 + (str[i++]-‘0‘);
14 s[idx].push_back(make_pair(ret-1,flag));
15 ret = 0;
16 flag = true;
17 } else i++;
18 }
19 }
20 bool check(int o){
21 for(int i = 0; i < m; ++i){
22 bool flag = false;
23 for(int j = s[i].size()-1; j >= 0; --j){
24 if(s[i][j].second == ((o>>s[i][j].first)&1)){
25 flag = true;
26 break;
27 }
28 }
29 if(!flag) return false;
30 }
31 return true;
32 }
33 int main(){
34 int T;
35 scanf("%d",&T);
36 while(T--){
37 scanf("%d %d",&n,&m);
38 getchar();
39 for(int i = 0; i < m; ++i){
40 s[i].clear();
41 gets(str);
42 exp2num(i);
43 }
44 bool ok = false;
45 for(int i = 0; i < (1<<n) && !ok; ++i)
46 ok = check(i);
47 puts(ok?"satisfiable":"unsatisfiable");
48 }
49 return 0;
50 }