Problem: Company "Robots industries" produces robots for territory protection. Robots protect triangle territories — right isosceles triangles with catheti parallel to North-South and East-West directions.

Owner of some land buys and sets robots on his territory to protect it. From time to time, businessmen want to build offices on that land and want to know how many robots will guard it. You are to handle these queries. 

Input

The first line contains integer N — width and height of the land, and integer Q — number of queries to handle.

Next Q lines contain queries you need to process.

Two types of queries: 

  1. 1 dir x y len — add a robot to protect a triangle. Depending on the value of dir, the values of x, y and len represent a different triangle: 
    * dir = 1: Triangle is defined by the points (x, y), (x + len, y), (x, y + len)
    * dir = 2: Triangle is defined by the points (x, y), (x + len, y), (x, y - len)
    * dir = 3: Triangle is defined by the points (x, y), (x - len, y), (x, y + len)
    * dir = 4: Triangle is defined by the points (x, y), (x - len, y), (x, y - len)
  2. 2 x y — output how many robots guard this point (robot guards a point if the point is inside or on the border of its triangle) 


  * 1 ≤ N ≤ 5000
  * 1 ≤ Q ≤ 105
  * 1 ≤ dir ≤ 4
  * All points of triangles are within range [1, N]
  * All numbers are positive integers 

Output

For each second type query output how many robots guard this point. Each answer should be in a separate line.

Examples

Input

17 10
1 1 3 2 4
1 3 10 3 7
1 2 6 8 2
1 3 9 4 2
2 4 4
1 4 15 10 6
2 7 7
2 9 4
2 12 2
2 13 8


Output

2
2
2
0
1

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
bool o;
char ch, SSS[1 << 17], *A = SSS, *B = SSS;
inline char gc() {
  return A == B && (B = (A = SSS) + fread(SSS, 1, 1 << 17, stdin), A == B)
             ? EOF
             : *A++;
}
template <typename _Tp>
inline void rd(_Tp &x);
template <typename _Tq>
inline void wr(_Tq x);
template <typename _Tp>
inline _Tp mx(_Tp x, _Tp y);
template <typename _Tp>
inline _Tp mn(_Tp x, _Tp y);
int n, m, up, x, y;
int opt[300001], type[300001], a[300001], b[300001], c[300001];
int ans[300001];
int s[600001];
int cnt;
struct p {
  int opt, x, y, v, id;
} q[600001];
inline void nw(int id, int type, int x, int y, int v = 0) {
  cnt++;
  q[cnt].id = id;
  q[cnt].opt = type;
  q[cnt].x = x;
  q[cnt].y = y;
  q[cnt].v = v;
}
inline void add(int x, int v) {
  while (x <= up) {
    s[x] += v;
    x += ((x) & (-x));
  }
}
inline int query(int x) {
  int tp = 0;
  while (x) {
    tp += s[x];
    x -= ((x) & (-x));
  }
  return tp;
}
inline bool cmp(p i, p j) { return i.x != j.x ? i.x < j.x : i.opt == 1; }
inline void solve1(int l, int r) {
  if (l == r) return;
  int m = (l + r) >> 1;
  solve1(l, m), solve1(m + 1, r);
  cnt = 0;
  for (int i = l; i <= m; i++) {
    if (type[i] == 1) {
      nw(i, 1, a[i], b[i], 1);
      nw(i, 1, a[i] + c[i] + 1, b[i], -1);
    }
  }
  for (int i = m + 1; i <= r; i++) {
    if (opt[i] == 2) nw(i, 2, a[i], b[i]);
  }
  stable_sort(q + 1, q + 1 + cnt, cmp);
  for (int i = 1; i <= cnt; i++) {
    if (q[i].opt == 1) {
      add(q[i].y, q[i].v);
      q[i].y = a[q[i].id] + b[q[i].id] + c[q[i].id] + 1;
    } else
      ans[q[i].id] += query(q[i].y);
  }
  for (int i = 1; i <= cnt; i++) {
    if (q[i].opt == 1)
      add(q[i].y, q[i].v);
    else
      ans[q[i].id] -= query(q[i].x + q[i].y);
  }
}
inline void solve2(int l, int r) {
  if (l == r) return;
  int m = (l + r) >> 1;
  solve2(l, m), solve2(m + 1, r);
  cnt = 0;
  for (int i = l; i <= m; i++) {
    if (type[i] == 4) {
      nw(i, 1, a[i] - c[i], a[i] + b[i] - c[i], 1);
      nw(i, 1, a[i] + 1, a[i] + b[i] - c[i], -1);
    }
  }
  for (int i = m + 1; i <= r; i++) {
    if (opt[i] == 2) nw(i, 2, a[i], b[i]);
  }
  stable_sort(q + 1, q + 1 + cnt, cmp);
  for (int i = 1; i <= cnt; i++) {
    if (q[i].opt == 1) {
      add(q[i].y, q[i].v);
      q[i].y = b[q[i].id] + 1;
    } else
      ans[q[i].id] += query(q[i].x + q[i].y);
  }
  for (int i = 1; i <= cnt; i++) {
    if (q[i].opt == 1)
      add(q[i].y, q[i].v);
    else
      ans[q[i].id] -= query(q[i].y);
  }
}
int main() {
  rd(n), rd(m), up = n << 1;
  for (int i = 1; i <= m; i++) {
    rd(opt[i]);
    if (opt[i] == 1)
      rd(type[i]), rd(a[i]), rd(b[i]), rd(c[i]);
    else
      rd(a[i]), rd(b[i]);
  }
  solve1(1, m), solve2(1, m);
  for (int i = 1; i <= m; i++) {
    x = a[i], y = b[i];
    a[i] = y, b[i] = n - x + 1;
    if (opt[i] == 1) {
      if (type[i] == 1 || type[i] == 4)
        type[i] = -1;
      else
        type[i] = type[i] == 2 ? 4 : 1;
    }
  }
  solve1(1, m), solve2(1, m);
  for (int i = 1; i <= m; i++)
    if (opt[i] == 2) wr(ans[i]), putchar(10);
}
template <typename _Tp>
inline void rd(_Tp &x) {
  o = 0;
  x = 0;
  while (ch ^ 45 && (ch < 48 || ch > 57)) ch = gc();
  if (ch == 45) o = 1, ch = gc();
  while (ch > 47 && ch < 58) {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = gc();
  }
  if (o) x = -x;
}
template <typename _Tp>
inline void wr(_Tp x) {
  if (x < 0) x = -x, putchar(45);
  if (x < 10) {
    putchar(x + 48);
    return;
  }
  wr(x / 10);
  putchar(x % 10 + 48);
}
template <typename _Tp>
inline _Tp mx(_Tp x, _Tp y) {
  return x > y ? x : y;
}
template <typename _Tp>
inline _Tp mn(_Tp x, _Tp y) {
  return x < y ? x : y;
}