#K12856. Common Delivery Point
Common Delivery Point
Common Delivery Point
You are given several delivery routes. Each route consists of a list of delivery points represented by integers. The task is to determine whether there is at least one delivery point that is common to all routes. In other words, if the routes are denoted as \(R_1, R_2, \ldots, R_n\), you need to check whether \(\bigcap_{i=1}^{n} R_i \neq \emptyset\). If such a common point exists, output yes
; otherwise, output no
.
The input is provided via standard input (stdin) and the output should be produced on standard output (stdout).
inputFormat
The first line of input contains an integer T representing the number of test cases. Each test case is formatted as follows:
- The first line contains an integer N, denoting the number of routes.
- The following N lines each contain space-separated integers representing the delivery points for that route.
Note: All input is read from stdin.
outputFormat
For each test case, output a single line containing yes
if there is at least one common delivery point among all routes; otherwise, output no
. The results for multiple test cases should be printed on separate lines. All output is written to stdout.
1
3
1 2 3
2 3 4
3 4 5
yes