#include<stdio.h> #include<stdlib.h> #include<string.h> #include<string> #include<queue> #include<set> #include<vector> #define maxn 20 using namespace std; typedef queue<int> Q; int main(){ set<Q> se; int t,n,a[maxn],flag=1,ff[maxn],nn=0; scanf("%d",&t); while(t--){ nn=0; flag=1; scanf("%d",&n); Q q; se.clear(); memset(a,0,sizeof(a)); memset(ff,0,sizeof(ff)); for(int i=0;i<n;i++){ scanf("%d",&a[i]); if(a[i]==0) nn++; q.push(a[i]); } if(nn==n){ printf("%s ","ZERO"); flag=0; } se.insert(q); while(flag==1){ int f=q.front(),m,b; int x=f; q.pop(); int j=0; for(int i=1;i<n;i++){ m=q.front(); q.pop(); b=abs(f-m); q.push(b); ff[j++]=b; f=m; } q.push(abs(x-f)); ff[j++]=abs(x-f); if(!se.count(q)){se.insert(q);} else{ printf("%s ","LOOP"); flag=0; } nn=0; for(int k=0;k<j;k++){ if(ff[k]==0) nn++; } if(nn==n) { printf("%s ","ZERO"); flag=0; } } } return 0; }