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;
template <typename T>
void chkmax(T &x, T y) {
  if (x < y) x = y;
}
template <typename T>
void chkmin(T &x, T y) {
  if (x > y) x = y;
}
inline int read() {
  int x = 0;
  char c = getchar();
  bool f = 0;
  while (c < 48) f |= c == '-', c = getchar();
  while (c > 47) x = x * 10 + (c ^ 48), c = getchar();
  return f ? -x : x;
}
const int maxn = 2e5 + 10, P = 1e9 + 7;
int Inc(int x, int y) { return x + y < P ? x + y : x + y - P; }
int Dec(int x, int y) { return x < y ? x - y + P : x - y; }
void Add(int &x, int y) {
  x += y;
  if (x >= P) x -= P;
}
void Sub(int &x, int y) {
  x -= y;
  if (x < 0) x += P;
}
int qp(int a, int k) {
  int res = 1;
  for (; k; k >>= 1, a = 1ll * a * a % P)
    if (k & 1) res = 1ll * res * a % P;
  return res;
}
int n = 1, q, A[maxn], deg[maxn], inv[maxn];
struct node {
  int op, x, y;
} dat[maxn];
vector<int> E[maxn];
int fa[maxn], sz[maxn], son[maxn], top[maxn], dfn[maxn];
void dfs(int u) {
  sz[u] = 1;
  for (int v : E[u]) {
    dfs(v), sz[u] += sz[v];
    if (sz[son[u]] < sz[v]) son[u] = v;
  }
}
void dfs2(int u, int tp) {
  static int now;
  dfn[u] = ++now, top[u] = tp;
  if (son[u]) dfs2(son[u], tp);
  for (int v : E[u])
    if (v != son[u]) dfs2(v, v);
}
int sum[maxn << 2], tag[maxn << 2], pro[maxn << 2];
void pushtag(int k, int x) {
  Add(sum[k], 1ll * x * pro[k] % P), Add(tag[k], x);
}
void pushdown(int k) {
  int &x = tag[k];
  if (x)
    pushtag(k << 1 | 1, x), pushtag(k << 1, 1ll * x * pro[k << 1 | 1] % P),
        x = 0;
}
int hf;
void add(int k, int l, int r, int ql, int qr) {
  if (ql <= l && r <= qr)
    return pushtag(k, hf), hf = 1ll * hf * pro[k] % P, void();
  pushdown(k);
  if (qr > ((l + r) >> 1)) add(k << 1 | 1, ((l + r) >> 1) + 1, r, ql, qr);
  if (ql <= ((l + r) >> 1)) add(k << 1, l, ((l + r) >> 1), ql, qr);
}
void upd(int k, int l, int r, int x, int p) {
  if (l == r) return pro[k] = p, void();
  pushdown(k);
  x <= ((l + r) >> 1) ? upd(k << 1, l, ((l + r) >> 1), x, p)
                      : upd(k << 1 | 1, ((l + r) >> 1) + 1, r, x, p),
      pro[k] = 1ll * pro[k << 1] * pro[k << 1 | 1] % P;
}
int query(int k, int l, int r, int x) {
  if (l == r) return sum[k];
  pushdown(k);
  return x <= ((l + r) >> 1) ? query(k << 1, l, ((l + r) >> 1), x)
                             : query(k << 1 | 1, ((l + r) >> 1) + 1, r, x);
}
void solve() {
  cin >> A[1] >> q;
  deg[1] = inv[1] = 1;
  for (int i = (2), iend = (q); i <= iend; ++i)
    inv[i] = 1ll * (P - P / i) * inv[P % i] % P;
  for (int i = (1), iend = (q); i <= iend; ++i) {
    if ((dat[i].op = read()) == 1) {
      dat[i].x = read(), dat[i].y = read();
      E[dat[i].x].push_back(++n), fa[n] = dat[i].x, dat[i].x = n;
    } else {
      dat[i].x = read();
    }
  }
  dfs(1), dfs2(1, 1), upd(1, 1, n, 1, 1), hf = A[1], add(1, 1, n, 1, 1);
  for (int i = (1), iend = (q); i <= iend; ++i) {
    int u = dat[i].x;
    if (dat[i].op == 1) {
      A[u] = dat[i].y;
      int f = fa[u], lst = query(1, 1, n, dfn[f]),
          su = 1ll * lst * inv[deg[f]] % P;
      int de = (su + A[u] + 1ll * deg[f] * A[u]) % P;
      hf = 1ll * de * inv[deg[f]] % P, add(1, 1, n, dfn[f], dfn[f]);
      upd(1, 1, n, dfn[f], ++deg[f]), upd(1, 1, n, dfn[u], ++deg[u]),
          hf = A[u], add(1, 1, n, dfn[u], dfn[u]);
      hf = de, f = fa[f];
      while (f) {
        add(1, 1, n, dfn[top[f]], dfn[f]);
        f = fa[top[f]];
      }
    } else {
      printf("%d\n", query(1, 1, n, dfn[u]));
    }
  }
}
signed main() {
  solve();
  return 0;
}