public void solve() throws IOException {
    int l = nextInt();
    int w = nextInt();
    char[][] input = new char[l][w];
    for (int x = 0; x < l; x++)
      input[x] = nextLine().toCharArray();
    char[][] ans = new char[l][w];

    for (int x = 0; x < l; x++) {
      for (int y = 0; y < w; y++) {
        if (input[x][y] == '-')
          ans[x][y] = '-';
        else {
          char up = '-', left = '-';
          if (x != 0)
            up = ans[x - 1][y];
          if (y != 0)
            left = ans[x][y - 1];
          if (up == '-')
            up = left;
          if (up == 'B')
            ans[x][y] = 'W';
          else
            ans[x][y] = 'B';
        }
        System.out.print(ans[x][y]);
      }
      System.out.println();
    }
  }