#include "testlib.h"

using namespace std;

int main (int argc, char **argv) {
  registerValidation(argc, argv);

  int n = inf.readInt(1, 300'000, "n");
  inf.readSpace();
  int qc = inf.readInt(1, 300'000, "q");
  inf.readEoln();

  bool ex23 = false;
  for (int i = 0; i < qc; i++) {
    int typ = inf.readInt(1, 3, "t");
    inf.readSpace();
    
    if (typ == 1) {
      int l = inf.readInt(1, n, "l");
      inf.readSpace();
      int r = inf.readInt(l, n, "r");
      inf.readEoln();

      if (validator.group() == "segtree") {
        int pwk = r + 1 - l;
        ensuref(__builtin_popcount(pwk) == 1, "r + 1 - l (in query %d) is not a power of two", i);
        ensuref(l % pwk == 0, "query %d is not of the form x << k, ((x + 1) << k) - 1", i);
      }
    } else {
      int x = inf.readInt(1, n, "x");
      inf.readEoln();

      ex23 = true;
    }
  }
  inf.readEof();

  ensuref(ex23, "no query of type 2 or 3 exists");
  if (validator.group() == "small") {
    ensuref(n <= 1000 && qc <= 1000, "n or qc exceeds limit for small test cases");
  }
}
