#include <stdio.h>
#include <stdlib.h>

// take an input stream of integer rgb pixel data and produce an output
// stream of "fat" pixels. a fat pixel is the transformation of an input
// pixel to one that is blown up to a 3x3 pixel. the input data must have
// a width of < the LINE_SIZE pixels.

#define LINE_SIZE 4096
int line[LINE_SIZE];

int ch;

void read_char() {
  if (ch == -1)
    return;
  else {
    ch = getchar();
    return;
  }
}

void skip_blanks() {
  while (ch == 32 || ch == 10 || ch == 13)
    ch = getchar();
  return;
}

int scan_int() {
  int sum;
  int negative;

  sum = 0; // initialize sum
  negative = 0; // initialize sign as positive

  skip_blanks();
     
  if (ch == 45) { // '-'
    negative = 1;  
    read_char();
  }

  while (ch >= 48 && ch <= 57) { // '0' .. '9'
    sum = sum * 10 + ch - 48;
    read_char();
  }

  if (negative == 1)
    sum = - sum;
  return sum;
}

void read_line(int line[], int width) {
  int i;
  for (i = 0; i < width; i++)
    line[i] = scan_int();
  return;
}

void output_line(int line[], int width, int scale) {
  int i;
  int j;
  int k;
  int value;
  for (k = 0; k < scale; k++)
    for (i = 0; i < width; i++)
      for (j = 0; j < scale; j++) {
        value = line[i];
        printf("%d", value);
        printf("\n");
      }
  return;
}

void output(int scale, int width, int height) {
  int i;
  for (i = 0; i < height; i++) {
    read_line(line, width);
    output_line(line, width, scale);
  }
  return;
}

int main() {
  int width;
  int height;
  int scale;
  int scaled;

  ch = ' ';
  
  // TODO make sure width is < LINE_SIZE
  width = scan_int();
  if (width >= LINE_SIZE) {
    printf("image width to big\n");
    printf("recompile fat with greater line size\n");
    exit(0);
  }
  height = scan_int();
  scale = 3;

  scaled = scale * width;
  printf("%d", scaled);
  printf("\n");
  scaled = scale * height;
  printf("%d", scaled);
  printf("\n");

  output(scale, width, height);

  return 0;
}
