| t | import sys | t | import sys | 
             | import struct |  | import struct | 
             |  |  |  | 
             | def read_bmp(data): |  | def read_bmp(data): | 
             |     file_length = len(data) |  |     file_length = len(data) | 
             |     if file_length < 26: |  |     if file_length < 26: | 
             |         print('Incorrect size') |  |         print('Incorrect size') | 
             |         return |  |         return | 
             |     try: |  |     try: | 
             |         bmp_header = data[:14] |  |         bmp_header = data[:14] | 
             |         signature, file_size, reserved1, reserved2, pixel_array_offset = |  |         signature, file_size, reserved1, reserved2, pixel_array_offset = | 
             |  struct.unpack('<2sIHHI', bmp_header) |  |  struct.unpack('<2sIHHI', bmp_header) | 
             |     except struct.error: |  |     except struct.error: | 
             |         print('Incorrect size') |  |         print('Incorrect size') | 
             |         return |  |         return | 
             |     if signature != b'BM': |  |     if signature != b'BM': | 
             |         print('Not a Windows BMP') |  |         print('Not a Windows BMP') | 
             |         return |  |         return | 
             |     if file_size != file_length: |  |     if file_size != file_length: | 
             |         print('Incorrect size') |  |         print('Incorrect size') | 
             |         return |  |         return | 
             |     try: |  |     try: | 
             |         dib_header_size = struct.unpack('<I', data[14:18])[0] |  |         dib_header_size = struct.unpack('<I', data[14:18])[0] | 
             |     except struct.error: |  |     except struct.error: | 
             |         print('Incorrect size') |  |         print('Incorrect size') | 
             |         return |  |         return | 
             |     valid_dib_sizes = [12, 16, 40, 52, 56, 64, 108, 124] |  |     valid_dib_sizes = [12, 16, 40, 52, 56, 64, 108, 124] | 
             |     if dib_header_size not in valid_dib_sizes: |  |     if dib_header_size not in valid_dib_sizes: | 
             |         print('Incorrect header size') |  |         print('Incorrect header size') | 
             |         return |  |         return | 
             |     if file_length < 14 + dib_header_size: |  |     if file_length < 14 + dib_header_size: | 
             |         print('Incorrect size') |  |         print('Incorrect size') | 
             |         return |  |         return | 
             |     dib_header = data[14:14 + dib_header_size] |  |     dib_header = data[14:14 + dib_header_size] | 
             |     if dib_header_size == 12: |  |     if dib_header_size == 12: | 
             |         try: |  |         try: | 
             |             _, width, height, planes, bits_per_pixel = struct.unpack('<I |  |             _, width, height, planes, bits_per_pixel = struct.unpack('<I | 
             | HHHH', dib_header[:12]) |  | HHHH', dib_header[:12]) | 
             |             compression = 0 |  |             compression = 0 | 
             |             pixel_array_size = 0 |  |             pixel_array_size = 0 | 
             |         except struct.error: |  |         except struct.error: | 
             |             print('Incorrect size') |  |             print('Incorrect size') | 
             |             return |  |             return | 
             |     elif dib_header_size >= 40: |  |     elif dib_header_size >= 40: | 
             |         try: |  |         try: | 
             |             unpack_format = '<IiiHHII' |  |             unpack_format = '<IiiHHII' | 
             |             unpack_size = struct.calcsize(unpack_format) |  |             unpack_size = struct.calcsize(unpack_format) | 
             |             fields = struct.unpack(unpack_format, dib_header[:unpack_siz |  |             fields = struct.unpack(unpack_format, dib_header[:unpack_siz | 
             | e]) |  | e]) | 
             |             _, width, height, planes, bits_per_pixel, compression, pixel |  |             _, width, height, planes, bits_per_pixel, compression, pixel | 
             | _array_size = fields |  | _array_size = fields | 
             |         except struct.error: |  |         except struct.error: | 
             |             print('Incorrect size') |  |             print('Incorrect size') | 
             |             return |  |             return | 
             |     else: |  |     else: | 
             |         print('Incorrect header size') |  |         print('Incorrect header size') | 
             |         return |  |         return | 
             |     if planes != 1: |  |     if planes != 1: | 
             |         print('Incorrect header size') |  |         print('Incorrect header size') | 
             |         return |  |         return | 
             |     abs_width = abs(width) |  |     abs_width = abs(width) | 
             |     abs_height = abs(height) |  |     abs_height = abs(height) | 
             |     if bits_per_pixel <= 0: |  |     if bits_per_pixel <= 0: | 
             |         print('Incorrect header size') |  |         print('Incorrect header size') | 
             |         return |  |         return | 
             |     bits_per_row = abs_width * bits_per_pixel |  |     bits_per_row = abs_width * bits_per_pixel | 
             |     bytes_per_row = (bits_per_row + 7) // 8 |  |     bytes_per_row = (bits_per_row + 7) // 8 | 
             |     padding = (4 - bytes_per_row % 4) % 4 |  |     padding = (4 - bytes_per_row % 4) % 4 | 
             |     row_size_padded = bytes_per_row + padding |  |     row_size_padded = bytes_per_row + padding | 
             |     computed_pixel_array_size = row_size_padded * abs_height |  |     computed_pixel_array_size = row_size_padded * abs_height | 
             |     if dib_header_size >= 40: |  |     if dib_header_size >= 40: | 
             |         specified_pixel_array_size = pixel_array_size |  |         specified_pixel_array_size = pixel_array_size | 
             |     else: |  |     else: | 
             |         specified_pixel_array_size = 0 |  |         specified_pixel_array_size = 0 | 
             |     size_matches = False |  |     size_matches = False | 
             |     padding_size = 0 |  |     padding_size = 0 | 
             |     if specified_pixel_array_size == 0: |  |     if specified_pixel_array_size == 0: | 
             |         size_matches = True |  |         size_matches = True | 
             |     elif specified_pixel_array_size == computed_pixel_array_size: |  |     elif specified_pixel_array_size == computed_pixel_array_size: | 
             |         size_matches = True |  |         size_matches = True | 
             |     elif specified_pixel_array_size == computed_pixel_array_size + 2: |  |     elif specified_pixel_array_size == computed_pixel_array_size + 2: | 
             |         size_matches = True |  |         size_matches = True | 
             |         padding_size = 2 |  |         padding_size = 2 | 
             |     else: |  |     else: | 
             |         size_matches = False |  |         size_matches = False | 
             |     if not size_matches: |  |     if not size_matches: | 
             |         print('Incorrect image size') |  |         print('Incorrect image size') | 
             |         return |  |         return | 
             |     compression_method = compression if dib_header_size >= 40 else 0 |  |     compression_method = compression if dib_header_size >= 40 else 0 | 
             |     print(abs_width, abs_height, bits_per_pixel, compression_method, pad |  |     print(abs_width, abs_height, bits_per_pixel, compression_method, pad | 
             | ding_size) |  | ding_size) | 
             | bmp_file = sys.stdin.buffer.read() |  | bmp_file = sys.stdin.buffer.read() | 
             | read_bmp(bmp_file) |  | read_bmp(bmp_file) |