Under construction

Still being built. Things may change

Today Is the OS Homework Deadline

Time limit1sMemory limit128 MB

Summary
Given a yearless deadline and a yearless report date, assign the report a plausible year and classify it as prior, after, same day, or out of range within a 7 day window.
Level

Medium6 of 10

Topics
Math, Implementation, Simulation
Solved
No attempts yet

Problem

Taekhee is a teaching assistant for an operating systems course. This assignment is simple: capture a screenshot of pintos running, print it, and submit it. Each student only needs to write their student ID, name, and submission date on the report. Since everyone knows the current year, the date is written without a year, using only month/day. For instance, a student writes 9/20 instead of 09/20/2005.

Before grading, Taekhee was checking old reports and scores to review past grading standards. Then this year's reports got mixed with old reports. Because the reports do not include a year and do not have grading results written on them, the report alone no longer reveals which year's assignment it came from. The assignment deadline also falls on the same month/day every year.

Taekhee wants to decide whether to grade each report by comparing the assignment deadline with the submission date written on the report.

Given the assignment deadline and each student's written submission date, write a program that prints the decision according to the output rules.

Input

The first line contains the number of test cases T. Each of the next T lines contains one test case, consisting of two dates. The first date is the assignment deadline, and the second date is the date written on the report.

The deadline is in m/d/y format. The year y is between 2000 and 2200 inclusive, and the date is always valid. The report date is in m/d format, and it is also a valid month/day.

Output

For each test case, print one of the following lines.

m/d/y IS n DAY(S) PRIOR: the report date is 1 through 7 days before the deadline.

m/d/y IS n DAY(S) AFTER: the report date is 1 through 7 days after the deadline.

SAME DAY: the report date and the deadline have the same month/day.

OUT OF RANGE: even after assigning an appropriate year to the report date, it is not within 7 days before or after the deadline.

m/d/y is the report date with the actual year that makes the comparison valid. The printed year y may be any year from 1999 through 2200 and does not have to equal the deadline year. Use DAY when n is 1, and DAYS otherwise.

Examples1

  1. Example 1

    Input
    7
    11/20/2005 11/21
    11/20/2005 11/17
    11/20/2005 11/20
    11/20/2005 11/13
    11/20/2005 11/28
    1/2/2005 12/30
    12/31/2100 1/3
    Expected output
    11/21/2005 IS 1 DAY AFTER
    11/17/2005 IS 3 DAYS PRIOR
    SAME DAY
    11/13/2005 IS 7 DAYS PRIOR
    OUT OF RANGE
    12/30/2004 IS 3 DAYS PRIOR
    1/3/2101 IS 3 DAYS AFTER