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>
const int N = 200005, mu = 1e9 + 7;
int in[N], out[N], idn, q[N], opt[N], f[N], tr[N << 2], tag[N << 2], w[N], d[N];
int Q, id[N], n, inv[N];
std::vector<int> e[N];
void dfs(int x) {
  in[x] = ++idn;
  for (int i : e[x]) dfs(i);
  out[x] = idn;
}
int ksm(int x, int y) {
  int ans = 1;
  for (; y; y >>= 1, x = x * 1ll * x % mu)
    if (y & 1) ans = ans * 1ll * x % mu;
  return ans;
}
void puttag(int x, int v) {
  tag[x] = tag[x] * 1ll * v % mu;
  tr[x] = tr[x] * 1ll * v % mu;
}
void pushdown(int x) {
  int t = tag[x];
  if (t != 1) {
    puttag(x << 1, t);
    puttag(x << 1 | 1, t);
    tag[x] = 1;
  }
}
void push_up(int x) { tr[x] = (tr[x << 1] + tr[x << 1 | 1]) % mu; }
void modify(int k, int L, int R, int l, int r, int v) {
  if (L == l && R == r) {
    puttag(k, v);
    return;
  }
  pushdown(k);
  int mid = (L + R) >> 1;
  if (r <= mid)
    modify(k << 1, L, mid, l, r, v);
  else if (l > mid)
    modify(k << 1 | 1, mid + 1, R, l, r, v);
  else {
    modify(k << 1, L, mid, l, mid, v);
    modify(k << 1 | 1, mid + 1, R, mid + 1, r, v);
  }
  push_up(k);
}
int query(int k, int L, int R, int l, int r) {
  if (L == l && R == r) return tr[k];
  pushdown(k);
  int mid = (L + R) >> 1;
  if (r <= mid) return query(k << 1, L, mid, l, r);
  if (l > mid) return query(k << 1 | 1, mid + 1, R, l, r);
  return (query(k << 1, L, mid, l, mid) +
          query(k << 1 | 1, mid + 1, R, mid + 1, r)) %
         mu;
}
void upd(int k, int l, int r, int x, int v) {
  if (l == r) {
    tr[k] = tag[k] * 1ll * v % mu;
    return;
  }
  pushdown(k);
  int mid = (l + r) >> 1;
  if (x <= mid)
    upd(k << 1, l, mid, x, v);
  else
    upd(k << 1 | 1, mid + 1, r, x, v);
  push_up(k);
}
int main() {
  scanf("%d%d", &w[1], &Q);
  n = 1;
  for (int i = 1; i <= Q; i++) {
    scanf("%d", &opt[i]);
    if (opt[i] == 1) {
      ++n;
      scanf("%d%d", &f[n], &w[n]);
      e[f[n]].push_back(n);
      id[i] = n;
    } else
      scanf("%d", &q[i]);
  }
  dfs(1);
  inv[0] = 1, inv[1] = 1;
  for (int i = 1; i <= n * 4; i++) tag[i] = 1;
  for (int i = 2; i <= n; i++) inv[i] = 1ll * (mu - mu / i) * inv[mu % i] % mu;
  d[1] = 1;
  upd(1, 1, n, 1, w[1]);
  for (int i = 1; i <= Q; i++) {
    if (opt[i] == 1) {
      int x = id[i], fa = f[x];
      d[x] = 1;
      upd(1, 1, n, in[x], w[x]);
      modify(1, 1, n, in[fa], out[fa], 1ll * inv[d[fa]] * (d[fa] + 1) % mu);
      d[fa]++;
    } else {
      int x = q[i];
      int ans = query(1, 1, n, in[x], out[x]);
      if (f[x])
        ans = ans * 1ll * ksm(query(1, 1, n, in[f[x]], in[f[x]]), mu - 2) % mu *
              w[f[x]] % mu;
      printf("%d\n", ans);
    }
  }
}