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 int64 = long long;
inline int getint() {
  register char ch;
  while (!isdigit(ch = getchar()))
    ;
  register int x = ch ^ '0';
  while (isdigit(ch = getchar())) x = (((x << 2) + x) << 1) + (ch ^ '0');
  return x;
}
constexpr int N = 2e5 + 1, Q = 2e5, mod = 1e9 + 7;
int w[N], n, dfn[N], par[N], size[N], s[N];
std::forward_list<int> e[N];
inline void add_edge(const int &u, const int &v) { e[u].push_front(v); }
struct Operation {
  int type, v, u;
};
Operation o[N];
void exgcd(const int &a, const int &b, int &x, int &y) {
  if (!b) {
    x = 1, y = 0;
    return;
  }
  exgcd(b, a % b, y, x);
  y -= a / b * x;
}
int inv(const int &x) {
  int ret, tmp;
  exgcd(x, mod, ret, tmp);
  return (ret % mod + mod) % mod;
}
void dfs(const int &x) {
  size[x] = 1;
  dfn[x] = ++dfn[0];
  for (auto &y : e[x]) {
    dfs(y);
    size[x] += size[y];
  }
}
class SegmentTree {
 private:
  int val[N << 2], tag[N << 2];
  void push_up(const int &p) { val[p] = (val[p << 1] + val[p << 1 | 1]) % mod; }
  void push_down(const int &p) {
    if (tag[p] == 1) return;
    tag[p << 1] = (int64)tag[p << 1] * tag[p] % mod;
    tag[p << 1 | 1] = (int64)tag[p << 1 | 1] * tag[p] % mod;
    val[p << 1] = (int64)val[p << 1] * tag[p] % mod;
    val[p << 1 | 1] = (int64)val[p << 1 | 1] * tag[p] % mod;
    tag[p] = 1;
  }

 public:
  void build(const int &p, const int &b, const int &e) {
    tag[p] = 1;
    if (b == e) return;
    const int mid = (b + e) >> 1;
    build(p << 1, b, mid);
    build(p << 1 | 1, mid + 1, e);
  }
  void add(const int &p, const int &b, const int &e, const int &x,
           const int &v) {
    (val[p] += v) %= mod;
    if (b == e) return;
    push_down(p);
    const int mid = (b + e) >> 1;
    if (x <= mid) add(p << 1, b, mid, x, v);
    if (x > mid) add(p << 1 | 1, mid + 1, e, x, v);
  }
  void mul(const int &p, const int &b, const int &e, const int &l, const int &r,
           const int &v) {
    if (b == l && e == r) {
      val[p] = (int64)val[p] * v % mod;
      tag[p] = (int64)tag[p] * v % mod;
      return;
    }
    push_down(p);
    const int mid = (b + e) >> 1;
    if (l <= mid) mul(p << 1, b, mid, l, std::min(mid, r), v);
    if (r > mid) mul(p << 1 | 1, mid + 1, e, std::max(mid + 1, l), r, v);
    push_up(p);
  }
  int query(const int &p, const int &b, const int &e, const int &l,
            const int &r) {
    if (b == l && e == r) {
      return val[p];
    }
    push_down(p);
    int ret = 0;
    const int mid = (b + e) >> 1;
    if (l <= mid) (ret += query(p << 1, b, mid, l, std::min(mid, r))) %= mod;
    if (r > mid)
      (ret += query(p << 1 | 1, mid + 1, e, std::max(mid + 1, l), r)) %= mod;
    return ret;
  }
};
SegmentTree t;
int main() {
  w[n = 1] = getint();
  const int q = getint();
  for (register int i = 0; i < q; i++) {
    o[i].type = getint();
    if (o[i].type == 1) {
      o[i].v = par[++n] = getint();
      add_edge(par[n], n);
      w[o[i].u = n] = getint();
    }
    if (o[i].type == 2) {
      o[i].v = getint();
    }
  }
  dfs(1);
  s[1] = 1;
  t.build(1, 1, n);
  t.add(1, 1, n, 1, w[1]);
  for (register int i = 0; i < q; i++) {
    const int &y = o[i].u, &x = o[i].v;
    if (o[i].type == 1) {
      t.add(1, 1, n, dfn[y],
            (int64)t.query(1, 1, n, dfn[x], dfn[x]) * inv(w[x]) % mod * w[y] %
                mod);
      t.mul(1, 1, n, dfn[x], dfn[x] + size[x] - 1,
            (int64)inv(s[x]) * (s[x] + 1) % mod);
      s[x] += s[y] = 1;
    }
    if (o[i].type == 2) {
      const int ans = t.query(1, 1, n, dfn[x], dfn[x] + size[x] - 1);
      if (x == 1) {
        printf("%d\n", ans);
        continue;
      }
      printf("%d\n",
             int((int64)ans * w[par[x]] % mod *
                 inv(t.query(1, 1, n, dfn[par[x]], dfn[par[x]])) % mod));
    }
  }
  return 0;
}