#K68982. Recall Chevrolet Vehicles

    ID: 32985 Type: Default 1000ms 256MiB

Recall Chevrolet Vehicles

Recall Chevrolet Vehicles

You are given one or more datasets. Each dataset consists of a set of year ranges during which certain Chevrolet vehicles were required to be recalled, and a list of vehicle model years. Your task is to determine, for each dataset, which vehicle model years fall within any of the recall intervals.

For each dataset:

  • The first line contains an integer n which indicates the number of recall ranges.
  • The next n lines each contain two integers s and e, representing a recall interval \( [s, e] \).
  • The following line contains a series of integers representing the model years to check.

The input ends with a line containing a single 0.

For each dataset, output the recalled years in ascending order separated by spaces. If no recalled year is found, output NONE instead.

inputFormat

The input is read from standard input (stdin) and consists of multiple datasets. For each dataset:

  • An integer n on a line indicating the number of recall ranges.
  • n subsequent lines, each containing two integers s and e (with \( s \le e \)) representing a recall interval \( [s, e] \).
  • A line with a list of integers separated by spaces representing the vehicle model years.

The input terminates with a line containing a single 0.

outputFormat

For each dataset, output a single line on standard output (stdout):

  • If there is at least one recalled model year, output the recalled years (those that fall within any of the recall intervals) in ascending order, separated by a single space.
  • If no recalled year exists for a dataset, output NONE.
## sample
2
2000 2005
2010 2015
1999 2003 2007 2012 2018
1
1990 2000
1985 1990 1992 1998 2002
0
2003 2012

1990 1992 1998

</p>