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 mo = 1e9 + 7;
template <class T>
void rd(T &x) {
  x = 0;
  int f = 0;
  char c = getchar();
  while (c > '9' || c < '0') {
    if (c == '-') f = 1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  if (f) x = -x;
}
void print(int x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10) print(x / 10);
  putchar('0' + x % 10);
}
int df, dfn[200005], dnf[200005];
int cnt, al[200005], cl[200005], kk[200005];
int n = 1, A[200005];
int Q1[200005], Q2[200005];
int fa[200005], sz[200005];
int shu[200005 << 2], su[200005 << 2], inv[200005];
int Q, P, V;
long long mul(long long a, int b) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % mo;
    a = a * a % mo;
    b >>= 1;
  }
  return ans;
}
void jia(int x, int y) {
  al[++cnt] = y;
  cl[cnt] = kk[x];
  kk[x] = cnt;
}
int dit(int x) { return x >= mo ? x - mo : x; }
void dfs(int x) {
  dfn[x] = ++df;
  for (int i = kk[x]; i; i = cl[i]) {
    dfs(al[i]);
  }
  dnf[x] = df;
}
void pushd(int bao) {
  su[bao << 1] = su[bao << 1] * 1ll * su[bao] % mo;
  su[bao << 1 | 1] = su[bao << 1 | 1] * 1ll * su[bao] % mo;
  shu[bao << 1] = shu[bao << 1] * 1ll * su[bao] % mo;
  shu[bao << 1 | 1] = shu[bao << 1 | 1] * 1ll * su[bao] % mo;
  su[bao] = 1;
}
void pushup(int bao) { shu[bao] = dit(shu[bao << 1] + shu[bao << 1 | 1]); }
void init(int l, int r, int bao) {
  su[bao] = 1;
  if (l == 1) shu[bao] = A[1];
  if (l == r) return;
  int mid = l + r >> 1;
  init(l, mid, bao << 1);
  init(mid + 1, r, bao << 1 | 1);
}
void qiu(int l, int r, int bao) {
  if (l == r) {
    V = su[bao];
    return;
  }
  int mid = l + r >> 1;
  if (su[bao] != 1) pushd(bao);
  if (Q <= mid)
    qiu(l, mid, bao << 1);
  else
    qiu(mid + 1, r, bao << 1 | 1);
}
void cg(int l, int r, int bao) {
  if (Q <= l && P >= r) {
    shu[bao] = shu[bao] * 1ll * V % mo;
    su[bao] = su[bao] * 1ll * V % mo;
    return;
  }
  int mid = l + r >> 1;
  if (su[bao] != 1) pushd(bao);
  if (Q <= mid) cg(l, mid, bao << 1);
  if (P > mid) cg(mid + 1, r, bao << 1 | 1);
  pushup(bao);
}
void aDd(int l, int r, int bao) {
  if (l == r) {
    shu[bao] = V;
    return;
  }
  int mid = l + r >> 1;
  if (su[bao] != 1) pushd(bao);
  if (Q <= mid)
    aDd(l, mid, bao << 1);
  else
    aDd(mid + 1, r, bao << 1 | 1);
  pushup(bao);
}
void qiu2(int l, int r, int bao) {
  if (Q <= l && P >= r) {
    V = dit(V + shu[bao]);
    return;
  }
  int mid = l + r >> 1;
  if (su[bao] != 1) pushd(bao);
  if (Q <= mid) qiu2(l, mid, bao << 1);
  if (P > mid) qiu2(mid + 1, r, bao << 1 | 1);
}
void Doit(int x) {
  sz[x] = 1;
  ++sz[fa[x]];
  Q = dfn[fa[x]];
  P = dnf[fa[x]];
  V = inv[sz[fa[x]] - 1] * 1ll * sz[fa[x]] % mo;
  cg(1, n, 1);
  Q = dfn[x];
  qiu(1, n, 1);
  V = V * 1ll * A[x] % mo;
  aDd(1, n, 1);
}
long long sol(int x) {
  long long as;
  Q = dfn[x];
  P = dnf[x];
  V = 0;
  qiu2(1, n, 1);
  as = V;
  if (fa[x]) {
    Q = dfn[fa[x]];
    qiu(1, n, 1);
    as = as * mul(V, mo - 2) % mo;
  }
  return as;
}
int main() {
  int q, x, y, z;
  rd(A[1]);
  rd(q);
  for (int i = 1; i <= q; ++i) {
    rd(x);
    if (x == 1) {
      rd(y);
      rd(z);
      jia(y, ++n);
      A[n] = z;
      fa[n] = y;
      Q1[i] = 1;
      Q2[i] = n;
    } else {
      Q1[i] = 2;
      rd(Q2[i]);
    }
  }
  for (int i = 1; i <= n; ++i) inv[i] = mul(i, mo - 2);
  init(1, n, 1);
  dfs(1);
  sz[1] = 1;
  for (int i = 1; i <= q; ++i) {
    x = Q2[i];
    if (Q1[i] == 1)
      Doit(x);
    else {
      print(sol(x));
      putchar('\n');
    }
  }
  return 0;
}