This page is still under construction.

Parts of this page are still being built. What you see may change.

Pizza veto voting

Time limit3sMemory limit256 MB

Summary
Decide whether your vetoes can keep your favorite pizza standing when Alice always vetoes the highest-calorie kind and Bob the lowest.
Level

Medium6 of 10

Topics
Greedy, Game theory, Simulation
Solved
No attempts yet

Problem

You are training for a programming contest with your team members Alice and Bob. After a few hours of training you want a break and some pizza. The three of you order one big pizza, so you have to settle on the kind first.

You have a favorite kind. Alice is on a diet, so she wants the pizza with the fewest calories. Bob is mean to Alice, so he wants the pizza with the most calories.

Voting for one kind would not settle anything, so you decide on veto voting. Alice vetoes one kind first, then Bob vetoes one, then you veto one. The order repeats with Alice, Bob and you again, until a single kind is left. Whoever is on turn must veto one of the remaining kinds.

Alice always vetoes the remaining pizza with the most calories, and Bob always vetoes the one with the fewest calories. You pick your vetoes so that your favorite pizza is the one left at the end. Decide whether you can make your favorite pizza the last kind standing.

Input

The first line has the number of kinds of pizza nn and the index of your favorite pizza pp (1≤n≤100 0001 \le n \le 100\,000, 1≤p≤n1 \le p \le n). Indices start at 1.

Each of the next nn lines describes one pizza: the calories cc (0≤c≤1 000 0000 \le c \le 1\,000\,000) and the name of the pizza ww, separated by a space. A name is a single word without spaces and is at most 100 characters long. The pizzas are given from the fewest calories to the most, and no two pizzas have the same number of calories.

Output

Print YES on one line if you can use your vetoes so that your favorite pizza is the one left at the end, and NO if you cannot.

Examples2

  1. Example 1

    Input
    5 2
    500 Margherita
    600 Salami
    700 Hawai
    800 Speciale
    900 Doener
    
    Expected output
    YES
    
  2. Example 2

    Input
    5 4
    500 Margherita
    600 Salami
    700 Hawai
    800 Speciale
    900 Doener
    
    Expected output
    NO