Problem

Description

You are given closed, integer intervals and integers .
Write a program that:
reads the number of intervals, their end points and integers from the standard input, computes the minimal size of a set of integers which has at least common elements with interval , for each , writes the answer to the standard output.

Input

The first line of the input contains an integer () – the number of intervals. The following n lines describe the intervals. The line of the input contains three integers , and separated by single spaces and such that and .

Output

The output contains exactly one integer equal to the minimal size of set sharing at least elements with interval , for each .