Problem: Genos and Saitama went shopping for Christmas trees. However, a different type of tree caught their attention, the exalted Power Tree. 

A Power Tree starts out as a single root vertex indexed 1. A Power Tree grows through a magical phenomenon known as an update. In an update, a single vertex is added to the tree as a child of some other vertex.

Every vertex in the tree (the root and all the added vertices) has some value vi associated with it. The power of a vertex is defined as the strength of the multiset composed of the value associated with this vertex (vi) and the powers of its direct children. The strength of a multiset is defined as the sum of all elements in the multiset multiplied by the number of elements in it. Or in other words for some multiset S: 

<image>

Saitama knows the updates that will be performed on the tree, so he decided to test Genos by asking him queries about the tree during its growth cycle.

An update is of the form 1 p v, and adds a new vertex with value v as a child of vertex p.

A query is of the form 2 u, and asks for the power of vertex u.

Please help Genos respond to these queries modulo 109 + 7.

Input

The first line of the input contains two space separated integers v1 and q (1 ≤ v1 < 109, 1 ≤ q ≤ 200 000) — the value of vertex 1 and the total number of updates and queries respectively.

The next q lines contain the updates and queries. Each of them has one of the following forms: 

  * 1 pi vi, if these line describes an update. The index of the added vertex is equal to the smallest positive integer not yet used as an index in the tree. It is guaranteed that pi is some already existing vertex and 1 ≤ vi < 109. 
  * 2 ui, if these line describes a query. It is guaranteed ui will exist in the tree. 



It is guaranteed that the input will contain at least one query.

Output

For each query, print out the power of the given vertex modulo 109 + 7.

Examples

Input

2 5
1 1 3
1 2 5
1 3 7
1 4 11
2 1


Output

344


Input

5 5
1 1 4
1 2 3
2 2
1 2 7
2 1


Output

14
94

Note

For the first sample case, after all the updates the graph will have vertices labelled in the following manner: 1 — 2 — 3 — 4 — 5

These vertices will have corresponding values: 2 — 3 — 5 — 7 — 11

And corresponding powers: 344 — 170 — 82 — 36 — 11

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int Q = 1000000007;
const int M = 200007;
inline int rd() {
  int x = 0;
  bool f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = 0;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - 48;
  return f ? x : -x;
}
int n, m;
int dd[M];
int pre[M];
int que[M], tque;
struct node {
  long long vd, ml, sum;
  long long tag;
  int ch[2], p;
  void init(long long ww, long long du) {
    tag = 0;
    ch[0] = ch[1] = p = 0;
    sum = ww;
    ml = vd = du;
  }
} a[M];
void pushup(int x) {
  a[x].ml = a[x].vd;
  if (a[x].ch[0]) a[x].ml = (a[a[x].ch[0]].ml * a[x].ml) % Q;
  if (a[x].ch[1]) a[x].ml = (a[x].ml * a[a[x].ch[1]].ml) % Q;
}
void totag(int x, long long d) {
  long long tp = 1;
  if (a[x].ch[1]) tp = a[a[x].ch[1]].ml;
  a[x].sum = (a[x].sum + (d * tp) % Q) % Q;
  a[x].tag = (a[x].tag + d) % Q;
}
void pushdown(int x) {
  if (a[x].tag) {
    long long tp = a[x].vd;
    if (a[x].ch[1])
      totag(a[x].ch[1], a[x].tag), tp = (tp * a[a[x].ch[1]].ml) % Q;
    if (a[x].ch[0]) totag(a[x].ch[0], (a[x].tag * tp) % Q);
    a[x].tag = 0;
  }
}
bool isrt(int x) {
  int y = a[x].p;
  return a[y].ch[0] != x && a[y].ch[1] != x;
}
void clear(int x) {
  tque = 0;
  for (; !isrt(x); x = a[x].p) que[++tque] = x;
  que[++tque] = x;
  for (; tque; tque--) pushdown(que[tque]);
}
void rot(int x) {
  int y = a[x].p;
  int z = a[y].p;
  int D = (a[y].ch[1] == x), ss = D ^ 1;
  if (!isrt(y)) a[z].ch[a[z].ch[1] == y] = x;
  a[x].p = z;
  a[y].p = x;
  if (a[x].ch[ss]) a[a[x].ch[ss]].p = y;
  a[y].ch[D] = a[x].ch[ss];
  a[x].ch[ss] = y;
  pushup(y);
  pushup(x);
}
void splay(int x) {
  int y, z;
  for (clear(x); !isrt(x); rot(x)) {
    y = a[x].p;
    z = a[y].p;
    if (isrt(y)) continue;
    if ((a[z].ch[0] == y) != (a[y].ch[0] == x))
      rot(x);
    else
      rot(y);
  }
  pushup(x);
}
void access(int x) {
  for (int t = 0; x; t = x, x = a[x].p) {
    splay(x);
    a[x].ch[1] = t;
    pushup(x);
  }
}
void ac(int x) {
  access(x);
  splay(x);
}
void link(int x, int y) {
  a[x].p = y;
  ac(x);
}
void mdf_d(int x, long long du) {
  ac(x);
  a[x].vd = du;
  pushup(x);
}
void mdf_sum(int x, long long del) {
  ac(x);
  totag(x, del);
}
long long getsum(int x) {
  ac(x);
  return a[x].sum;
}
int main() {
  int i, kd, x, y, z;
  n = 1;
  z = rd();
  a[1].init(z, 1);
  dd[1] = 1;
  pre[1] = 0;
  m = rd();
  while (m--) {
    kd = rd();
    if (kd == 1) {
      y = rd(), z = rd();
      x = ++n;
      a[x].init(z, 1);
      dd[x] = 1;
      pre[x] = y;
      link(x, y);
      dd[y]++;
      mdf_d(y, dd[y]);
      long long tp = getsum(y);
      mdf_sum(y, z);
      if (pre[y]) mdf_sum(pre[y], tp);
    } else {
      x = rd();
      long long ans = dd[x];
      ans = (ans * getsum(x)) % Q;
      printf("%I64d\n", ans);
    }
  }
  return 0;
}