First Presence of an Opposite Pair X88445


Statement
 

pdf   zip

thehtml

Write a program that receives on stdin lines containing integers and writes out the first line in which both some number and its opposite appear; the line is to be reported together with the number itself.

Input

The input is a sequence of zero or more lines. Each line cointains zero or more integers, separated by spaces.

Output

Output is the first line of the input in which both some number n and its opposite −n appear, preceded by the non-negative case of the number itself, with ": " (colon-single space) as separator. If several such numbers appear, the earliest-starting pair is to be reported. If there is no such line, the program must write "Not found."

Public test cases
  • Input

    -1 3 -2 -3 1 2
    -4 4 -5 5 -6 6

    Output

    1: -1 3 -2 -3 1 2
    
    
  • Input

    5 -4 3 -2 1
    3 2 1 2 3
    2 1 0 1 2
    111 -111

    Output

    0: 2 1 0 1 2
    
    
  • Input

    9 8 7 6 5
    4 3 2 1

    Output

    Not found.
    
  • Input

    49 38 27 16
    101 222 3 -3 222 -101 -222
    23 24 -23 -24
    

    Output

    101: 101 222 3 -3 222 -101 -222
    
    
  • Information
    Author
    José Luis Balcázar
    Language
    English
    Official solutions
    Python
    User solutions
    Python