#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;++i)
using namespace std;
template<typename T>inline void ckmax(T &x,T y){x=x<y?y:x;}
template<typename T>inline void ckmin(T &x,T y){x=x>y?y:x;}
template<typename T=int>inline T read(){
T res=0,f=1; char k;
while(!isdigit(k=getchar())) if(k=='-') f=-1;
while(isdigit(k)) res=res*10+k-'0',k=getchar();
return res*f;
}
template<typename T>inline void print(T x,bool fl=1){
if(x<0) putchar('-'),x=-x;
if(x>=10) print(x/10,0);
putchar(x%10+'0');
if(fl) putchar('\n');
}
const int N=5010;
int a[N],b[N],n,ta[N],tb[N];
bool Fail=0;
inline void solve(int l,int r){
if(a[l]==a[r]){
if(r-l+1>=3) Fail=1;
return ;
}
int c1=l-1,c2=r+1;
rep(i,l,r) if(a[i]&1) ta[++c1]=a[i]/2,tb[c1]=b[i];
rep(i,l,r) if(a[i]%2==0) ta[--c1]=a[i]/2,tb[c1]=b[i];
rep(i,l,r) a[i]=ta[i],b[i]=tb[i];
solve(l,cl); solve(cr,r);
return ;
}
int main(){
int T=read();
while(T--){
n=read();
for(int i=1;i<=n;++i) b[i]=a[i]=read();
solve(1,n);
if(Fail){
Fail=0;
puts("NO");
continue;
}
puts("YES");
for(int i=1;i<n;++i) printf("%d ",b[i]);
printf("%d\n",b[n]);
}
return 0;
}