Under construction

Still being built. Things may change

Cube Net

Time limit2sMemory limit128 MB

Summary
Given three 6x6 grids each marking six connected unit cells, decide for each whether the shape folds into a valid cube net.
Level

Medium6 of 10

Topics
Simulation, Math, Implementation
Solved
No attempts yet

Problem

Six unit squares joined edge to edge may form a net of a cube. A net is a shape that can be folded along its shared edges to make exactly one cube.

The shape in the first illustration can be folded into a cube.

The next shape also consists of six connected unit squares, but it cannot be folded into a cube.

Given a shape made of six unit squares, write a program that determines whether it is a net of a cube.

Input

Three data sets are given. Each data set consists of 6 lines, and each line contains 6 numbers separated by spaces. Every number is either 0 or 1.

A 1 represents a square, and a 0 represents an empty cell. In each data set, exactly six cells are 1, and the squares form one connected shape.

Output

For the three data sets, output one line per data set in the same order as the input. Print yes if the shape is a net of a cube, and no otherwise.

Examples1

  1. Example 1

    Input
    0 0 0 0 0 0
    0 0 0 0 0 0
    0 0 1 0 0 0
    0 1 1 1 1 0
    0 0 1 0 0 0
    0 0 0 0 0 0
    0 1 1 0 0 0
    0 1 0 0 0 0
    0 1 0 0 0 0
    1 1 0 0 0 0
    0 0 0 0 0 0
    0 0 0 0 0 0
    0 0 0 0 0 0
    0 0 0 1 1 0
    0 0 1 1 0 0
    0 0 0 1 1 0
    0 0 0 0 0 0
    0 0 0 0 0 0
    Expected output
    yes
    yes
    no