#include<bits/stdc++.h>   #define fo(i,a,b) for(int i=a;i<=b;i++)   #define fd(i,a,b) for(int i=a;i>=b;i--)   using namespace std;      typedef long long LL;   typedef pair<int,int> pr;      const int maxn=505;      int n,m;   char mp[maxn][maxn];      int T;   int main()   {    scanf( %d ,&T);    while (T--)    {     scanf( %d %d ,&n,&m);     fo(i,1,n) scanf( %s ,mp[i]+1);          fo(i,1,n) if (i%3==1)      fo(j,1,m) mp[i][j]= X ;     fo(i,1,n) if (i%3==1 && i+3<=n)     {      bool pd=0;      fo(j,1,m) if (mp[i+1][j]== X )      {       mp[i+2][j]= X ;       pd=1;       break;      }      if (pd) continue;      fo(j,1,m) if (mp[i+2][j]== X )      {       mp[i+1][j]= X ;       pd=1;       break;      }      if (pd) continue;      mp[i+1][1]=mp[i+2][1]= X ;     }     if (n%3==0)     {      fo(j,1,m) if (mp[n][j]== X ) mp[n-1][j]= X ;     }          fo(i,1,n) printf( %s n ,mp[i]+1);    }   }