PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#CC0000059. Hộp nằm trong hộp (Box in Box)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Hộp nằm trong hộp (Box in Box)

Box in Box

Source: AtCoder

Version: Phuoc Hung OJ Extended

Problem Statement

Given nn rectangular boxes that may be rotated, decide whether there are two distinct boxes such that the three dimensions of one are each strictly smaller than the corresponding dimensions of the other after suitable rotations.

Input

The first line gives nn. Each of the next nn lines gives the three side lengths of a box.

Output

Print Yes if such a pair exists, otherwise No.

Subtasks

  • Subtask 1 (20 points): 2≤n≤202\le n\le20; 1≤hi,wi,di≤1091\le h_i,w_i,d_i\le10^9.
  • Subtask 2 (30 points): 2≤n≤15002\le n\le1500; 1≤hi,wi,di≤1091\le h_i,w_i,d_i\le10^9.
  • Subtask 3 (50 points): 2≤n≤2000002\le n\le200000; 1≤hi,wi,di≤1091\le h_i,w_i,d_i\le10^9.

Examples

Input

3
19 8 22
10 24 12
15 25 11

Output

Yes

Explanation

After sorting side lengths, box 2 is (10,12,24) and box 3 is (11,15,25), so the second fits strictly inside the third.