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 maxn = 200005, mo = int(1e9) + 7, LIMIT = 1500, BLOCK = 450;
struct node {
  int tag, ds, v;
} t[maxn * 4];
struct quer {
  int ty, u, v;
} a[maxn];
vector<int> lk[maxn];
int dfn[maxn], r[maxn], refer[maxn], cnt;
int d[maxn], v[maxn], fa[maxn], q, n;
int pow(int a, int b) {
  int tmp = 1;
  for (; b; b >>= 1, a = a * 1ll * a % mo)
    if (b & 1) tmp = tmp * 1ll * a % mo;
  return tmp;
}
void dfs(int now) {
  dfn[now] = ++cnt;
  refer[cnt] = now;
  for (auto p : lk[now]) dfs(p);
  r[now] = cnt;
}
void read(int &x) {
  char c;
  while (c = getchar(), c < '0' || c > '9')
    ;
  x = c - 48;
  while (c = getchar(), c >= '0' && c <= '9') x = x * 10 + c - 48;
}
void build(int l, int r, int jd) {
  t[jd].tag = 1;
  if (l == r) {
    if (l == 1) t[jd].ds = 1, t[jd].v = v[1];
  } else {
    int mid = l + r >> 1;
    build(l, mid, jd << 1), build(mid + 1, r, jd << 1 | 1);
    t[jd].v = (t[jd << 1].v + t[jd << 1 | 1].v) % mo;
  }
}
void mark(int jd, int d) {
  t[jd].tag = t[jd].tag * 1ll * d % mo, t[jd].ds = t[jd].ds * 1ll * d % mo,
  t[jd].v = t[jd].v * 1ll * d % mo;
}
void activate(int l, int r, int p, int d, int jd) {
  if (l == r) {
    t[jd].ds = d, t[jd].v = d * 1ll * v[refer[l]] % mo;
  } else {
    int mid = l + r >> 1;
    if (t[jd].tag > 1)
      mark(jd << 1, t[jd].tag), mark(jd << 1 | 1, t[jd].tag), t[jd].tag = 1;
    if (p <= mid)
      activate(l, mid, p, d, jd << 1);
    else
      activate(mid + 1, r, p, d, jd << 1 | 1);
    t[jd].v = (t[jd << 1].v + t[jd << 1 | 1].v) % mo;
  }
}
int query_d(int l, int r, int p, int jd) {
  if (p < l || p > r) return 1;
  if (l == r) return t[jd].ds;
  int mid = l + r >> 1;
  if (t[jd].tag > 1)
    mark(jd << 1, t[jd].tag), mark(jd << 1 | 1, t[jd].tag), t[jd].tag = 1;
  if (p <= mid) return query_d(l, mid, p, jd << 1);
  return query_d(mid + 1, r, p, jd << 1 | 1);
}
int query(int l, int r, int i, int j, int jd) {
  if (j < l || i > r) return 0;
  if (i <= l && r <= j) return t[jd].v;
  if (t[jd].tag > 1)
    mark(jd << 1, t[jd].tag), mark(jd << 1 | 1, t[jd].tag), t[jd].tag = 1;
  int mid = l + r >> 1;
  return (query(l, mid, i, j, jd << 1) + query(mid + 1, r, i, j, jd << 1 | 1)) %
         mo;
}
void mark(int l, int r, int i, int j, int v, int jd) {
  if (j < l || i > r) return;
  if (i <= l && r <= j)
    mark(jd, v);
  else {
    int mid = l + r >> 1;
    if (t[jd].tag > 1)
      mark(jd << 1, t[jd].tag), mark(jd << 1 | 1, t[jd].tag), t[jd].tag = 1;
    mark(l, mid, i, j, v, jd << 1), mark(mid + 1, r, i, j, v, jd << 1 | 1);
    t[jd].v = (t[jd << 1].v + t[jd << 1 | 1].v) % mo;
  }
}
int main() {
  n = 1;
  read(v[1]), read(q);
  for (int i = 1; i <= q; i++) {
    read(a[i].ty), read(a[i].u);
    if (a[i].ty == 1) {
      read(v[++n]);
      fa[n] = a[i].u, lk[a[i].u].push_back(n);
      a[i].v = n;
    }
  }
  dfs(1);
  for (int i = 1; i <= n; i++) d[i] = 1;
  build(1, n, 1);
  for (int i = 1; i <= q; i++) {
    int ty = a[i].ty, u = a[i].u;
    if (ty == 1) {
      mark(1, n, dfn[u], r[u], (d[u] + 1) * 1ll * pow(d[u], mo - 2) % mo, 1);
      activate(1, n, dfn[a[i].v], query_d(1, n, dfn[u], 1), 1);
      d[u]++;
    } else
      cout << query(1, n, dfn[u], r[u], 1) * 1ll *
                  pow(query_d(1, n, dfn[fa[u]], 1), mo - 2) % mo
           << endl;
  }
  return 0;
}