#include <iostream>
#include <algorithm>
using namespace std;

const int M = 3000;
int field[M][M];

int main() {
  int N; cin >> N;
  for (int I = 1; I <= N; ++I) {

    int rows, cols; cin >> rows >> cols;
    for (int y = 0; y < rows; ++y)
      for (int x = 0; x < cols; ++x)
        cin >> field[y][x];

    for (int y = 1; y < rows; ++y) field[y][0] += field[y-1][0];
    for (int x = 1; x < cols; ++x) field[0][x] += field[0][x-1];
    for (int y = 1; y < rows; ++y)
      for (int x = 1; x < cols; ++x)
        // because all fields have values >= 0, field[y-1][x] and field[y][x-1]
        // are always >= field[y-1][x-1], so we can ignore the last case
        field[y][x] += max(field[y-1][x], field[y][x-1]);

    cout << "Scenario #" << I << ":\n";
    cout << field[rows-1][cols-1] << endl << endl;
  }
}

