#include<bits/stdc++.h>
using namespace std;
const int N = 13;
int T, m;
int n, t, x[N], y[N], L[N], R[N];
char op[N];
bool sp[N];
void slove() {
scanf("%d %d", &n, &t);
for (int i = 0; i < m; i++) {
op[i] = getchar();
while (op[i] != '?' && op[i] != '+' && op[i] != '-' && op[i] == '.') op[i] = getchar();
L[i] = R[i] = 0; sp[i] = 0;
if (op[i] == '.') continue;
if (op[i] == '-') {
scanf("%d", &x[i]);
continue;
}
if (op[i] == '+') {
scanf("%d/%d", &x[i], &y[i]);
L[i] = R[i] = (x[i] - 1) * 20 + y[i];
n--;
continue;
}
if (op[i] == '?') {
scanf("%d/%d", &x[i], &y[i]); sp[i] = 1;
L[i] = 20 * (y[i] - x[i]) + 240; R[i] = 20 * (y[i] - 1) + 299;
}
}
for (int S = 0; S < (1 << m); S++) {
bool yes = 1; int num = 0, sL = 0, sR = 0;
for (int i = 0; i < n; i++) {
if (op[i] == '+' && !((S >> i) & 1)) {yes = 0; break;}
if ((op[i] == '-' || op[i] == '.') && ((S >> i) & 1)) {yes = 0; break;}
if (op[i] == '?' && ((S >> i) & 1)) num++;
if ((S >> i) & 1) sL += L[i], sR += R[i];
}
if (num != n || !yes) continue;
if (t < sL || t > sR) continue;
for (int i = 0; i < n; i++)
if (op[i] == '?') {
if (!((S >> i) & 1)) {
op[i] = '-'; x[i] = y[i];
continue;
}
sL -= L[i]; sR -= R[i]; int tm = 0;
for (int j = L[i]; j <= R[i]; j++) {
if (sL + j <= t && t <= sR + j) {
tm = j; break;
}
}
int xx = (tm - 240) / 20, yy = tm - xx * 20;
while (xx + 1 > y[i]) xx--, yy += 20;
x[i] = xx + 1; y[i] = yy; t -= tm;
op[i] = '+';
}
else {
if ((S >> i) & 1) {
sL -= L[i]; sR -= R[i];//L[i]=R[i]
t -= L[i];
}
}
printf("Yes\n");
for (int i = 0; i < n; i++) {
putchar(op[i]);
if (op[i] == '.') continue;
putchar(' ');
if (op[i] == '-') printf("%d\n", x[i]);
if (op[i] == '+') printf("%d/%d\n", x[i], y[i]);
}
return ;
}
printf("No\n");
}
int main() {
scanf("%d %d", &T, &m);
while (T--) {
slove();
}
return 0;
}