/* This is R6.30
 * 
 * 
 */

public class R630 {
  public static void main(String[] args) {
    int ROWS = 7, COLUMNS = 8; 
    int[][] values = new int[ROWS][COLUMNS];  
    // (a) this is already done at allocation 
    R630.show( values ); // proof 
    // (b) checkerboard pattern: 
    for (int i = 0; i < ROWS; i++)
      for (int j = 0; j < COLUMNS; j++)
        if (((i + j) % 2) == 0) 
          values[i][j] = 1;
    R630.show( values ); // proof     
    // (c) fill only the top and bottom rows 
    for (int j = 0; j < COLUMNS; j++)
      values[0][j] = 4; // putting 4s in there (instead of 0s)
    for (int j = 0; j < COLUMNS; j++)
      values[ROWS-1][j] = 8; // putting 8s in there (instead of 0s)    
    R630.show( values ); // proof     
    // (d) compute the sum of all elements: 
    int sum = 0; 
    for (int i = 0; i < ROWS; i++)
      for (int j = 0; j < COLUMNS; j++)
        sum = sum + values[i][j]; 
    System.out.println( sum ); 
    // (e) print the array in tabular form: show, below. 
  }
  public static void show(int[][] a) {
    for (int row = 0; row < a.length; row++) { 
      for (int col = 0; col < a[row].length; col++) {
        System.out.print( a[row][col] + " " );    
      }
      System.out.println(); 
    }
    System.out.println("-------------------");       
  }
}