#include <bits/stdc++.h>
struct request {
  int l0, l1, r0, r1, w0, w1;
};
struct matrix_item {
  int value;
  matrix_item* right;
  matrix_item* down;
  matrix_item() : value(0), right(nullptr), down(nullptr) {}
};
matrix_item* read_data(int& queries) {
  int n, m;
  scanf("%d%d%d", &n, &m, &queries);
  matrix_item* root = new matrix_item();
  matrix_item* tmp = root;
  for (int i = 1; i <= m; ++i) {
    tmp->right = new matrix_item();
    tmp = tmp->right;
  }
  matrix_item* prevRow = root;
  for (int i = 1; i <= n; ++i) {
    matrix_item* curRow = prevRow->down = new matrix_item();
    matrix_item* curRowStart = curRow;
    for (int j = 1; j <= m; ++j) {
      curRow->right = new matrix_item();
      curRow = curRow->right;
      prevRow = prevRow->right;
      prevRow->down = curRow;
      scanf("%d", &curRow->value);
    }
    prevRow = curRowStart;
  }
  return root;
}
request read_request() {
  request result{0, 0, 500, 500, 500, 500};
  scanf("%d%d%d%d%d%d", &result.l0, &result.l1, &result.r0, &result.r1,
        &result.w0, &result.w1);
  return result;
}
matrix_item* find_element(matrix_item* matrix, int r, int c) {
  matrix_item* node = matrix;
  for (int i = 1; i < r; ++i) {
    node = node->down;
  }
  for (int j = 1; j < c; ++j) {
    node = node->right;
  }
  return node;
}
void swap_next_row(matrix_item*& p0, matrix_item*& p1, int cnt) {
  for (int i = 0; i < cnt; ++i) {
    p0 = p0->right;
    p1 = p1->right;
    std::swap(p0->down, p1->down);
  }
}
void swap_next_col(matrix_item*& p0, matrix_item*& p1, int cnt) {
  for (int i = 0; i < cnt; ++i) {
    p0 = p0->down;
    p1 = p1->down;
    std::swap(p0->right, p1->right);
  }
}
void apply_request(matrix_item* matrix, const request& r) {
  matrix_item* lBefore = find_element(matrix, r.l0, r.l1);
  matrix_item* rBefore = find_element(matrix, r.r0, r.r1);
  matrix_item *tmpL = lBefore, *tmpR = rBefore;
  swap_next_row(tmpL, tmpR, r.w1);
  swap_next_col(tmpL, tmpR, r.w0);
  tmpL = lBefore, tmpR = rBefore;
  swap_next_col(tmpL, tmpR, r.w0);
  swap_next_row(tmpL, tmpR, r.w1);
}
void do_work(matrix_item* matrix, int queries) {
  for (int i = 0; i < queries; ++i) {
    request r = read_request();
    apply_request(matrix, r);
  }
}
void print(matrix_item* matrix) {
  bool is_row_printable = false;
  for (matrix_item* next_row; matrix != nullptr; matrix = next_row) {
    next_row = matrix->down;
    bool is_column_printable = false;
    for (matrix_item *node = matrix, *next; node != nullptr; node = next) {
      next = node->right;
      if (is_column_printable) {
        printf("%d ", node->value);
      }
      is_column_printable = is_row_printable;
    }
    if (is_row_printable) {
      printf("\n");
    }
    is_row_printable = true;
  }
}
int main() {
  int queries = 0;
  auto matrix = read_data(queries);
  do_work(matrix, queries);
  print(matrix);
  return 0;
}
