This page is still under construction.

Parts of this page are still being built. What you see may change.

Dividing

Time limit1sMemory limit128 MB

Summary
Given counts of marbles worth 1 to 6, decide whether the collection can be split into two sets of equal total value.
Level

Medium6 of 10

Topics
Dynamic programming, Greedy, Bit manipulation
Solved
No attempts yet

Problem

Marsha and Bill jointly own a collection of marbles. They want to split the collection between them so that each receives an equal share.

This would be easy if every marble were worth the same, because then they could just split the collection in half by count. Unfortunately, some marbles are larger or more beautiful than others, so Marsha and Bill assign each marble a value: a natural number between 11 and 66. Now they want to divide the marbles so that each person gets the same total value.

It may be impossible to divide the marbles this way, even when the total value of all marbles is even. For example, with one marble of value 11, one of value 33, and two of value 44, there is no way to split them into two sets of equal value.

Write a program that decides whether a fair partition of the marbles exists.

Input

Each line of the input describes one collection of marbles to be divided. A line contains six non-negative integers n1,n2,…,n6n_1, n_2, \ldots, n_6, where nin_i is the number of marbles of value ii. For instance, the collection above is described by the line 1 0 1 2 0 0. The total number of marbles in any collection is at most 2000020000.

The input ends with a line containing 0 0 0 0 0 0; do not process this line.

Output

For each collection, output Collection #k:, where kk is the number of the collection (starting from 11), and on the next line print either Can be divided. or Can't be divided..

Print a blank line between consecutive collections.

Examples3

  1. Example 1

    Input
    1 0 1 2 0 0
    1 0 0 0 1 1
    0 0 0 0 0 0
    
    Expected output
    Collection #1:
    Can't be divided.
    
    Collection #2:
    Can be divided.
    
  2. Example 2

    Input
    2 0 0 0 0 0
    0 0 0 0 0 0
    
    Expected output
    Collection #1:
    Can be divided.
    
  3. Example 3

    Input
    1 0 0 0 0 0
    0 0 0 0 0 0
    
    Expected output
    Collection #1:
    Can't be divided.