#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
struct node{
int po;
int op;
int pen=0;
int fro=0;
int anssub=0;
int anspe=0;
}a[100];
bool cmp(node x,node y){
return x.op>y.op;
}
bool cp(node x,node y){
return x.po<y.po;
}
int n,t;
void prin(){
printf("Yes\n");
sort(a+1,a+1+t,cp);
for(int i=1;i<=t;i++){
if(a[i].op==-10){
printf(".\n");
}else if(a[i].op==-1){
printf("- %d\n",a[i].pen/20);
}else if(a[i].op==100){
printf("- %d\n",a[i].pen/20+a[i].fro);
}else if(a[i].op==1){
printf("+ %d/%d\n",a[i].anssub,a[i].anspe);
}
}
}
int sel[100];
int A[100];
bool check(int k,int sum,int final){
for(int i=1;i<=k;i++){
sum+=240;
sum+=a[sel[i]].pen;//固有罚时
a[sel[i]].anspe=240;
a[sel[i]].anssub=a[sel[i]].pen/20+1;//最后一发通过
}
if(sum>final){
return 0;
}
for(int i=1;i<=k;i++){
if(sum+(a[sel[i]].fro-1)*20+59<final){
a[sel[i]].anssub+=(a[sel[i]].fro-1);
a[sel[i]].anspe=299;
sum+=(a[sel[i]].fro-1)*20+59;
}else{
int ok=final-sum;
int ss=min(ok/20,a[sel[i]].fro-1);
assert(a[sel[i]].fro>0);
// int ss=ok/20;
a[sel[i]].anssub+=ss;
a[sel[i]].anspe+=(ok-ss*20);
sum=final;
}
}
return (sum==final);
}
void dfs(int cur,int k,int& jd,int num,int sum,int final){
if(jd==1){
return;
}
if(cur==k+1){
jd=check(k,sum,final);
if(jd==1){
for(int x=1;x<=k;x++){
a[sel[x]].op=1;
}
prin();
return ;
}
}else{
for(int i=1;i<=num&&jd==0;i++){
if(jd==0&&(cur==1||sel[cur-1]<i)&&A[i]==0){
sel[cur]=i;
A[i]=1;
dfs(cur+1,k,jd,num,sum,final);
A[i]=0;
}else continue;
}
}
}
void solve(int j){
int finalac,finalpe;
scanf("%d %d",&finalac,&finalpe);
int cnt=0;//ac数
int cnt1=0;//问号
int sum=0;//penalty
for(int i=1;i<=t;i++){
char ch;string s;
cin>>ch;
a[i].fro=0;a[i].pen=0;a[i].po=i;a[i].anspe=0;a[i].anssub=0;//init
if(ch=='+'){
cnt++;
a[i].op=1;
}else if(ch=='-'){
a[i].op=-1;
}else if(ch=='?'){//?
a[i].op=100;
cnt1++;
}else{
a[i].op=-10;
}
int sub=0;
int pen=0;
if(ch=='+'){
cin>>s;
int chan=1;
for(int ix=0;ix<s.length();ix++){
if(s[ix]=='/'){
a[i].pen=(sub-1)*20;
chan=0;
}
if(chan){
sub+=(int)(s[ix]-48);
}
if(!chan&&s[ix]!='/'){
pen=pen*10+(int)(s[ix]-48);
}
}
a[i].anspe=pen;
a[i].pen+=pen;
a[i].fro=0;
sum+=a[i].pen;
a[i].anssub=sub;
}else if(ch=='?'){
int x,y;
scanf("%d %d",&x,&y);
a[i].pen=(y-x)*20;
a[i].fro=x;
}else if(ch=='-'){
int x;scanf("%d",&x);
a[i].pen=x*20;//没过
}
}
int need=finalac-cnt;//还要ac几题
if(need<0||need>cnt1){//ac多了||问号不够
printf("No\n");
return;
}
sort(a+1,a+1+t,cmp);
int jd=0;
for(int i=0;i<100;i++) {A[i]=0;sel[i]=0;}
dfs(1,need,jd,cnt1,sum,finalpe);//cnt1=?
if(j==12){
cout<<"Yes"<<"\n";
// cout<<finalac<<"&&"<<finalpe<<"|||";
for(int i=5;i<=6;i++){
cout<<a[i].op<<"&&";
if(a[i].op==1){
cout<<(a[i].pen-a[i].anspe)/20+1<"&&"<<a[i].anspe<<"|||";
}else if(a[i].op==-1){
cout<<a[i].pen/20<<"|||";
}else{
cout<<a[i].fro<<"&&"<<a[i].pen/20<<"|||";
}
}
}
if(jd==0){
printf("No\n");
}
}
int main(){
scanf("%d %d",&n,&t);
for(int j=1;j<=n;j++){
solve(j);
}
return 0;
}
/*
2 6
4 806
+ 1/6
? 3 4
+ 4/183
- 2
+ 3/217
.
1 13
2 742
? 1 3
? 4 10
? 4 6
+ 1/17
*/