#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int n;
string s[8];
int d[6] = {-3, -2, -1, 1, 2, 3};

void dfs(int y, int x) {
  s[y][x] = '0';
  for (int i = 0; i < 6; i++) {
    int ny = y + d[i], nx = x;
    if (ny >= 0 && ny < 8 && s[ny][nx] == '1') {
      dfs(ny, nx);
    }
  }
  for (int i = 0; i < 6; i++) {
    int ny = y, nx = x + d[i];
    if (nx >= 0 && nx < 8 && s[ny][nx] == '1') {
      dfs(ny, nx);
    }
  }
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> n;
  for (int i = 0; i < n; i++) {
    int X, Y;
    for (int j = 0; j < 8; j++) {
      cin >> s[j];
    }
    cin >> X >> Y;
    X--, Y--;
    dfs(Y, X);
    cout << "Data " << i + 1 << ":" << endl;
    for (int j = 0; j < 8; j++) {
      cout << s[j] << endl;
    }
  }

  return 0;
}
