Problem: It is only a few days until Seollal (Korean Lunar New Year), and Jaehyun has invited his family to his garden. There are kids among the guests. To make the gathering more fun for the kids, Jaehyun is going to run a game of hide-and-seek.

The garden can be represented by a n × m grid of unit cells. Some (possibly zero) cells are blocked by rocks, and the remaining cells are free. Two cells are neighbors if they share an edge. Each cell has up to 4 neighbors: two in the horizontal direction and two in the vertical direction. 

Since the garden is represented as a grid, we can classify the cells in the garden as either "black" or "white". The top-left cell is black, and two cells which are neighbors must be different colors. Cell indices are 1-based, so the top-left corner of the garden is cell (1, 1).

Jaehyun wants to turn his garden into a maze by placing some walls between two cells. Walls can only be placed between neighboring cells. If the wall is placed between two neighboring cells a and b, then the two cells a and b are not neighboring from that point. One can walk directly between two neighboring cells if and only if there is no wall directly between them. 

A maze must have the following property. For each pair of free cells in the maze, there must be exactly one simple path between them. A simple path between cells a and b is a sequence of free cells in which the first cell is a, the last cell is b, all cells are distinct, and any two consecutive cells are neighbors which are not directly blocked by a wall.

At first, kids will gather in cell (1, 1), and start the hide-and-seek game. A kid can hide in a cell if and only if that cell is free, it is not (1, 1), and has exactly one free neighbor. Jaehyun planted roses in the black cells, so it's dangerous if the kids hide there. So Jaehyun wants to create a maze where the kids can only hide in white cells.

You are given the map of the garden as input. Your task is to help Jaehyun create a maze.

Input

Your program will be judged in multiple test cases.

The first line contains the number of test cases t. (1 ≤ t ≤ 100). Afterward, t test cases with the described format will be given.

The first line of a test contains two integers n, m (2 ≤ n, m ≤ 20), the size of the grid.

In the next n line of a test contains a string of length m, consisting of the following characters (without any whitespace): 

  * O: A free cell. 
  * X: A rock. 



It is guaranteed that the first cell (cell (1, 1)) is free, and every free cell is reachable from (1, 1). 

If t ≥ 2 is satisfied, then the size of the grid will satisfy n ≤ 10, m ≤ 10. In other words, if any grid with size n > 10 or m > 10 is given as an input, then it will be the only input on the test case (t = 1).

Output

For each test case, print the following:

If there are no possible mazes, print a single line NO.

Otherwise, print a single line YES, followed by a grid of size (2n-1) × (2m-1) denoting the found maze. The rules for displaying the maze follows. All cells are indexed in 1-base.

  * For all 1 ≤ i ≤ n, 1 ≤ j ≤ m, if the cell (i, j) is free cell, print 'O' in the cell (2i-1, 2j-1). Otherwise, print 'X' in the cell (2i-1, 2j-1). 
  * For all 1 ≤ i ≤ n, 1 ≤ j ≤ m-1, if the neighboring cell (i, j), (i, j+1) have wall blocking it, print ' ' in the cell (2i-1, 2j). Otherwise, print any printable character except spaces in the cell (2i-1, 2j). A printable character has an ASCII code in range [32, 126]: This includes spaces and alphanumeric characters. 
  * For all 1 ≤ i ≤ n-1, 1 ≤ j ≤ m, if the neighboring cell (i, j), (i+1, j) have wall blocking it, print ' ' in the cell (2i, 2j-1). Otherwise, print any printable character except spaces in the cell (2i, 2j-1) 
  * For all 1 ≤ i ≤ n-1, 1 ≤ j ≤ m-1, print any printable character in the cell (2i, 2j). 



Please, be careful about trailing newline characters or spaces. Each row of the grid should contain exactly 2m-1 characters, and rows should be separated by a newline character. Trailing spaces must not be omitted in a row.

Example

Input


4
2 2
OO
OO
3 3
OOO
XOO
OOO
4 4
OOOX
XOOX
OOXO
OOOO
5 6
OOOOOO
OOOOOO
OOOOOO
OOOOOO
OOOOOO


Output


YES
OOO
  O
OOO
NO
YES
OOOOO X
  O O  
X O O X
  O    
OOO X O
O O   O
O OOOOO
YES
OOOOOOOOOOO
  O   O   O
OOO OOO OOO
O   O   O  
OOO OOO OOO
  O   O   O
OOO OOO OOO
O   O   O  
OOO OOO OOO

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
#pragma GCC optimize("-O2")
using namespace std;
void err(istream_iterator<string> it) { cerr << endl; }
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << "\t";
  err(++it, args...);
}
template <typename T1, typename T2>
ostream& operator<<(ostream& c, pair<T1, T2>& v) {
  c << "(" << v.first << "," << v.second << ")";
  return c;
}
template <template <class...> class TT, class... T>
ostream& operator<<(ostream& out, TT<T...>& c) {
  out << "{ ";
  for (auto& x : c) out << x << " ";
  out << "}";
  return out;
}
const int LIM = 805, MOD = 1e9 + 7;
const long double EPS = 1e-9;
int read() {
  int xx = 0, ff = 1;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') ff = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    xx = (xx << 3) + (xx << 1) + ch - '0';
    ch = getchar();
  }
  return xx * ff;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
struct groundset {
  int from;
  int to;
  bool in_ind_set;
  bool in_y1;
  bool in_y2;
  int bfs_par;
  groundset() {
    from = 0;
    to = 0;
    in_ind_set = 0;
    in_y1 = 0;
    in_y2 = 0;
    bfs_par = 0;
  }
};
vector<groundset> v;
vector<int> ind_set;
int n, m;
int c[21][21];
int cov[21][21];
int link[405];
int sz[405];
int comp[405];
vector<int> adj[405];
int tin[405], tout[405];
int in_out_t;
bool visited[405];
int find(int x) {
  if (x == link[x]) return x;
  return link[x] = find(link[x]);
}
void unite(int a, int b) {
  a = find(a);
  b = find(b);
  if (a == b) return;
  if (sz[a] < sz[b]) swap(a, b);
  sz[a] += sz[b];
  link[b] = a;
}
int conv(int i, int j) { return i * m + j; }
pair<int, int> revcon(int val) {
  pair<int, int> ans;
  ans = make_pair(val / m, val % m);
  return ans;
}
bool is_black(pair<int, int> p) {
  if ((p.first == 0) && (p.second == 0)) return 0;
  if ((p.first + p.second) % 2 == 0) return 1;
  return 0;
}
void dfs(int node) {
  visited[node] = 1;
  tin[node] = in_out_t++;
  for (auto& r : adj[node]) {
    if (visited[r]) continue;
    unite(r, node);
    dfs(r);
  }
  tout[node] = in_out_t++;
}
void prep_graphic_matroid() {
  for (int i = 0; i < n * m; ++i) adj[i].clear();
  for (auto& r : ind_set) {
    adj[v[r].from].push_back(v[r].to);
    adj[v[r].to].push_back(v[r].from);
  }
  for (int i = 0; i < n * m; ++i) {
    tin[i] = -1;
    tout[i] = -1;
    link[i] = i;
    sz[i] = 1;
    visited[i] = 0;
    comp[i] = 0;
  }
  in_out_t = 0;
  for (int i = 0; i < n * m; ++i) {
    if (!visited[i]) dfs(i);
  }
  for (int i = 0; i < n * m; ++i) {
    comp[i] = find(i);
  }
  return;
}
bool can_add_graphic(int id) {
  int from = v[id].from;
  int to = v[id].to;
  return (comp[from] != comp[to]);
}
bool is_anc(int node1, int node2) {
  if (tin[node2] >= tin[node1] && tout[node2] <= tout[node1]) return 1;
  return 0;
}
bool can_exchange_graphic(int id1, int id2) {
  int f1 = v[id1].from, t1 = v[id1].to;
  int f2 = v[id2].from, t2 = v[id2].to;
  assert(comp[f2] == comp[t2]);
  if (comp[f1] != comp[t1]) return 1;
  if (comp[f1] != comp[f2]) return 0;
  int num_anc_1 = 0;
  if (is_anc(f2, t2)) swap(f2, t2);
  if (is_anc(f2, f1)) num_anc_1++;
  if (is_anc(f2, t1)) num_anc_1++;
  if (num_anc_1 == 1) return 1;
  return 0;
}
void prep_uniform_matroid() {
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cov[i][j] = 0;
    }
  }
  for (auto& r : ind_set) {
    pair<int, int> from = revcon(v[r].from);
    pair<int, int> to = revcon(v[r].to);
    if (is_black(from)) cov[from.first][from.second]++;
    if (is_black(to)) cov[to.first][to.second]++;
  }
  return;
}
bool can_add_uniform(int id) {
  pair<int, int> from = revcon(v[id].from);
  pair<int, int> to = revcon(v[id].to);
  pair<int, int> blk = from;
  if (!is_black(from)) blk = to;
  if (!is_black(to) && !is_black(from)) return 0;
  if (cov[blk.first][blk.second] < 2) return 1;
  return 0;
}
bool can_exchange_uniform(int id1, int id2) {
  pair<int, int> f1 = revcon(v[id1].from), t1 = revcon(v[id1].to);
  pair<int, int> f2 = revcon(v[id2].from), t2 = revcon(v[id2].to);
  pair<int, int> act1 = f1, act2 = f2;
  if (!is_black(f1)) act1 = t1;
  if ((!is_black(t1)) && !is_black(f1)) return 0;
  if (cov[act1.first][act1.second] < 2) return 1;
  if (!is_black(f2)) act2 = t2;
  return (act1 == act2);
}
void print(int id) {
  pair<int, int> from = revcon(v[id].from);
  pair<int, int> to = revcon(v[id].to);
  cout << " " << from.first << " " << from.second << " " << to.first << " "
       << to.second << " ";
}
bool augment() {
  int start = -3;
  int endpt = -2;
  int not_vis = -1;
  ind_set.clear();
  for (int i = 0; i < v.size(); ++i) {
    v[i].in_y1 = 0;
    v[i].in_y2 = 0;
    v[i].bfs_par = not_vis;
    if (v[i].in_ind_set) ind_set.push_back(i);
  }
  prep_uniform_matroid();
  prep_graphic_matroid();
  queue<int> q;
  for (int i = 0; i < v.size(); ++i) {
    if (v[i].in_ind_set) continue;
    if (can_add_uniform(i)) {
      v[i].bfs_par = start;
      v[i].in_y1 = 1;
      q.push(i);
    }
    if (can_add_graphic(i)) {
      v[i].in_y2 = 1;
    }
  }
  int end = endpt;
  while (!q.empty()) {
    int t = q.front();
    q.pop();
    if (v[t].in_ind_set) {
      for (int i = 0; i < v.size(); ++i) {
        if (v[i].bfs_par != not_vis) continue;
        if (v[i].in_ind_set) continue;
        if (!can_exchange_uniform(i, t)) continue;
        q.push(i);
        v[i].bfs_par = t;
      }
    } else {
      if (v[t].in_y2) {
        end = t;
        break;
      }
      for (int i = 0; i < v.size(); ++i) {
        if (v[i].bfs_par != not_vis) continue;
        if (!v[i].in_ind_set) continue;
        if (!can_exchange_graphic(t, i)) continue;
        q.push(i);
        v[i].bfs_par = t;
      }
    }
  }
  if (end == endpt) return 0;
  while (true) {
    v[end].in_ind_set ^= 1;
    end = v[end].bfs_par;
    if (end == start) break;
  }
  return 1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int tests = 1;
  cin >> tests;
  while (tests--) {
    v.clear();
    cin >> n >> m;
    int curr = 0;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < m; ++j) {
        char x;
        cin >> x;
        if (x == 'O') {
          c[i][j] = 1;
        } else {
          c[i][j] = 0;
        }
      }
    }
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < m; ++j) {
        if (c[i][j] == 0) continue;
        if (i + 1 < n && c[i + 1][j] == 1) {
          v.emplace_back();
          v.back().from = conv(i, j);
          v.back().to = conv(i + 1, j);
        }
        if (j + 1 < m && c[i][j + 1] == 1) {
          v.emplace_back();
          v.back().from = conv(i, j);
          v.back().to = conv(i, j + 1);
        }
      }
    }
    while (augment())
      ;
    bool pos = 1;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < m; ++j) {
        if ((i + j) % 2 == 1) continue;
        if ((i == 0) && (j == 0)) continue;
        if (c[i][j] == 0) continue;
        if (cov[i][j] != 2) pos = 0;
      }
    }
    if (!pos) {
      cout << "NO" << '\n';
      continue;
    }
    cout << "YES" << '\n';
    for (int i = 0; i < n * m; ++i) {
      link[i] = i;
      sz[i] = 1;
    }
    for (auto& r : ind_set) {
      int from = v[r].from;
      int to = v[r].to;
      assert(find(from) != find(to));
      unite(from, to);
    }
    char outp[2 * n + 1][2 * m + 1];
    for (int i = 0; i < 2 * n + 1; ++i) {
      for (int j = 0; j < 2 * m + 1; ++j) {
        outp[i][j] = ' ';
      }
    }
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < m; ++j) {
        if (c[i][j])
          outp[2 * i + 1][2 * j + 1] = 'O';
        else
          outp[2 * i + 1][2 * j + 1] = 'X';
      }
    }
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < m; ++j) {
        if (c[i][j] == 0) continue;
        if (i + 1 < n && c[i + 1][j] == 1) {
          if (find(conv(i, j)) != find(conv(i + 1, j))) {
            unite(conv(i, j), conv(i + 1, j));
            outp[2 * i + 2][2 * j + 1] = 'A';
          }
        }
        if (j + 1 < m && c[i][j + 1] == 1) {
          if (find(conv(i, j)) != find(conv(i, j + 1))) {
            unite(conv(i, j), conv(i, j + 1));
            outp[2 * i + 1][2 * j + 2] = 'A';
          }
        }
      }
    }
    for (auto& r : ind_set) {
      pair<int, int> from = revcon(v[r].from);
      pair<int, int> to = revcon(v[r].to);
      if (to.second == from.second + 1) {
        outp[2 * from.first + 1][2 * from.second + 2] = 'A';
      } else if (to.first == from.first + 1) {
        outp[2 * from.first + 2][2 * from.second + 1] = 'A';
      }
    }
    for (int i = 1; i < 2 * n; ++i) {
      for (int j = 1; j < 2 * m; ++j) {
        cout << outp[i][j];
      }
      cout << '\n';
    }
  }
  return 0;
}