#include <bits/stdc++.h>
using namespace std;
namespace IO {
char ibuf[(1 << 21) + 1], *iS, *iT;
char Get() {
  return (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, (1 << 21) + 1, stdin),
                      (iS == iT ? EOF : *iS++))
                   : *iS++);
}
int read() {
  int x = 0, c = Get();
  while (!isdigit(c)) c = Get();
  while (isdigit(c)) x = x * 10 + c - 48, c = Get();
  return x;
}
long long readl() {
  long long x = 0;
  int c = Get();
  while (!isdigit(c)) c = Get();
  while (isdigit(c)) x = x * 10 + c - 48, c = Get();
  return x;
}
}  // namespace IO
using namespace IO;
int inc(int a, int b) {
  a += b;
  return a >= 1000000 ? a - 1000000 : a;
}
long long mul(int a, int b) { return 1ll * a * b; }
struct node {
  int x, y;
  node(int a = 0, int b = 0) { x = a, y = b; }
};
int operator<(node a, node b) { return a.x < b.x || (a.x == b.x && a.y < b.y); }
int on(node l, node r, node p) {
  return mul(r.x - l.x, p.y) >= mul(r.x - l.x, l.y) + mul(r.y - l.y, p.x - l.x);
}
set<node> s;
long long m;
void ins(int dps, int cost) {
  auto it = s.lower_bound(node(dps, cost)), las = prev(it);
  if (it != s.end() && cost >= it->y) return;
  if (it != s.end() && on(*las, *it, node(dps, cost))) return;
  it = (s.emplace(dps, cost)).first;
  while (next(it) != s.end() && next(it)->x == dps) s.erase(next(it));
  while (prev(it) != s.begin() && on(*prev(prev(it)), *it, *prev(it)))
    s.erase(prev(it));
}
int bat(int lim, int hit) {
  auto it = s.lower_bound(node((hit + lim - 1) / lim, 0)), las = prev(it);
  if (it == s.end()) return 0;
  if (mul(it->y, lim) <= m) return 1;
  return mul(mul(lim, it->x - las->x), las->y) +
             mul(hit - lim * las->x, it->y - las->y) <=
         mul(m, it->x - las->x);
}
int main() {
  int n, i, o, k = 0, x, a, b;
  n = read(), m = readl(), o = 1, s.emplace(0, 0);
  for (i = 1; i <= n; ++i) {
    x = read(), a = read(), b = read();
    if (o) a = inc(a, k) + 1, b = inc(b, k) + 1;
    if (x == 1)
      ins(a, b);
    else if (bat(a, b))
      k = i, puts("YES");
    else
      puts("NO");
  }
}

### Prompt

Create a solution in cpp for the following problem:

Vova plays a computer game known as Mages and Monsters. Vova's character is a mage. Though as he has just started, his character knows no spells.

Vova's character can learn new spells during the game. Every spell is characterized by two values xi and yi — damage per second and mana cost per second, respectively. Vova doesn't have to use a spell for an integer amount of seconds. More formally, if he uses a spell with damage x and mana cost y for z seconds, then he will deal x·z damage and spend y·z mana (no rounding). If there is no mana left (mana amount is set in the start of the game and it remains the same at the beginning of every fight), then character won't be able to use any spells. It is prohibited to use multiple spells simultaneously.

Also Vova can fight monsters. Every monster is characterized by two values tj and hj — monster kills Vova's character in tj seconds and has hj health points. Mana refills after every fight (or Vova's character revives with full mana reserve), so previous fights have no influence on further ones.

Vova's character kills a monster, if he deals hj damage to it in no more than tj seconds using his spells (it is allowed to use more than one spell in a fight) and spending no more mana than he had at the beginning of the fight. If monster's health becomes zero exactly in tj seconds (it means that the monster and Vova's character kill each other at the same time), then Vova wins the fight.

You have to write a program which can answer two types of queries:

  * 1 x y — Vova's character learns new spell which deals x damage per second and costs y mana per second. 
  * 2 t h — Vova fights the monster which kills his character in t seconds and has h health points. 



Note that queries are given in a different form. Also remember that Vova's character knows no spells at the beginning of the game.

For every query of second type you have to determine if Vova is able to win the fight with corresponding monster.

Input

The first line contains two integer numbers q and m (2 ≤ q ≤ 105, 1 ≤ m ≤ 1012) — the number of queries and the amount of mana at the beginning of every fight.

i-th of each next q lines contains three numbers ki, ai and bi (1 ≤ ki ≤ 2, 1 ≤ ai, bi ≤ 106). 

Using them you can restore queries this way: let j be the index of the last query of second type with positive answer (j = 0 if there were none of these). 

  * If ki = 1, then character learns spell with x = (ai + j) mod 106 + 1, y = (bi + j) mod 106 + 1. 
  * If ki = 2, then you have to determine if Vova is able to win the fight against monster with t = (ai + j) mod 106 + 1, h = (bi + j) mod 106 + 1. 

Output

For every query of second type print YES if Vova is able to win the fight with corresponding monster and NO otherwise.

Example

Input

3 100
1 4 9
2 19 49
2 19 49


Output

YES
NO

Note

In first example Vova's character at first learns the spell with 5 damage and 10 mana cost per second. Next query is a fight with monster which can kill character in 20 seconds and has 50 health points. Vova kills it in 10 seconds (spending 100 mana). Next monster has 52 health, so Vova can't deal that much damage with only 100 mana.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
namespace IO {
char ibuf[(1 << 21) + 1], *iS, *iT;
char Get() {
  return (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, (1 << 21) + 1, stdin),
                      (iS == iT ? EOF : *iS++))
                   : *iS++);
}
int read() {
  int x = 0, c = Get();
  while (!isdigit(c)) c = Get();
  while (isdigit(c)) x = x * 10 + c - 48, c = Get();
  return x;
}
long long readl() {
  long long x = 0;
  int c = Get();
  while (!isdigit(c)) c = Get();
  while (isdigit(c)) x = x * 10 + c - 48, c = Get();
  return x;
}
}  // namespace IO
using namespace IO;
int inc(int a, int b) {
  a += b;
  return a >= 1000000 ? a - 1000000 : a;
}
long long mul(int a, int b) { return 1ll * a * b; }
struct node {
  int x, y;
  node(int a = 0, int b = 0) { x = a, y = b; }
};
int operator<(node a, node b) { return a.x < b.x || (a.x == b.x && a.y < b.y); }
int on(node l, node r, node p) {
  return mul(r.x - l.x, p.y) >= mul(r.x - l.x, l.y) + mul(r.y - l.y, p.x - l.x);
}
set<node> s;
long long m;
void ins(int dps, int cost) {
  auto it = s.lower_bound(node(dps, cost)), las = prev(it);
  if (it != s.end() && cost >= it->y) return;
  if (it != s.end() && on(*las, *it, node(dps, cost))) return;
  it = (s.emplace(dps, cost)).first;
  while (next(it) != s.end() && next(it)->x == dps) s.erase(next(it));
  while (prev(it) != s.begin() && on(*prev(prev(it)), *it, *prev(it)))
    s.erase(prev(it));
}
int bat(int lim, int hit) {
  auto it = s.lower_bound(node((hit + lim - 1) / lim, 0)), las = prev(it);
  if (it == s.end()) return 0;
  if (mul(it->y, lim) <= m) return 1;
  return mul(mul(lim, it->x - las->x), las->y) +
             mul(hit - lim * las->x, it->y - las->y) <=
         mul(m, it->x - las->x);
}
int main() {
  int n, i, o, k = 0, x, a, b;
  n = read(), m = readl(), o = 1, s.emplace(0, 0);
  for (i = 1; i <= n; ++i) {
    x = read(), a = read(), b = read();
    if (o) a = inc(a, k) + 1, b = inc(b, k) + 1;
    if (x == 1)
      ins(a, b);
    else if (bat(a, b))
      k = i, puts("YES");
    else
      puts("NO");
  }
}

```