Calculating Ages

Interview

Time limit1sMemory limit128 MB

Summary
Given a birth date and a reference date, compute the person's full, counting, and year ages on the reference date.
Level

Easy3 of 10

Topics
Math, Implementation
Solved
No attempts yet

Problem

In Korea there are three kinds of age.

  • Full age: the international standard, and the only kind of age Korean law uses.
  • Counting age: when Koreans usually ask your age, they mean counting age.
  • Year age: used by law to classify people uniformly.

Full age is computed from the birthday. When a person is born, their age is 0, and it increases by 1 each time a birthday passes. For example, a person born on March 5, 2003 is 0 years old until March 4, 2004, and 1 year old from March 5, 2004 to March 4, 2005.

Counting age is computed from the year of birth. When a person is born, their age is 1, and it increases by 1 each time the year changes. For example, a person born on March 5, 2003 is 1 year old until December 31, 2003, and 2 years old from January 1, 2004 to December 31, 2004.

Year age is computed from the year of birth, and equals the current year minus the year of birth. For example, a person born on March 5, 2003 is 0 years old until December 31, 2003, and 1 year old from January 1, 2004 to December 31, 2004.

Given a person's date of birth and a reference date, write a program that computes the person's full age, counting age, and year age as of the reference date.

Input

The first line gives the year, month, and day on which the person was born. The date of birth is separated by spaces, and is always a valid date.

The second line gives the reference date. The reference date is also separated by spaces, and is a valid date.

The date of birth given in the input is equal to or earlier than the reference date.

The years given in the input are greater than or equal to 1900 and less than or equal to 2100.

Output

On the first line print the full age, on the second line the counting age, and on the third line the year age.

Examples5

  1. Example 1

    Input
    2003 3 5
    2003 4 5
    
    Expected output
    0
    1
    0
    
  2. Example 2

    Input
    2003 3 5
    2004 1 1
    
    Expected output
    0
    2
    1
    
  3. Example 3

    Input
    2005 1 1
    2007 1 1
    
    Expected output
    2
    3
    2
    
  4. Example 4

    Input
    2005 12 31
    2007 1 1
    
    Expected output
    1
    3
    2
    
  5. Example 5

    Input
    2006 1 1
    2007 1 1
    
    Expected output
    1
    2
    1