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;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int p[200000 + 5], v[200000 + 5], Q, head[200000 + 5], cnt,
    tot = 1, size[200000 + 5], mx[200000 + 5];
int son[200000 + 5], dep[200000 + 5], fa[200000 + 5], top[200000 + 5],
    nl[200000 + 5], nr[200000 + 5], dn, inv[200000 + 5];
struct edge {
  int to, next;
} e[200000 + 5];
inline void ins(int f, int t) {
  e[++cnt] = (edge){t, head[f]};
  head[f] = cnt;
}
void Pre(int x) {
  size[x] = 1;
  mx[x] = 0;
  for (int i = head[x]; i; i = e[i].next) {
    dep[e[i].to] = dep[x] + 1;
    fa[e[i].to] = x;
    Pre(e[i].to);
    size[x] += size[e[i].to];
    if (size[e[i].to] > size[mx[x]]) mx[x] = e[i].to;
  }
}
void Dfs(int x, int tp) {
  top[x] = tp;
  nl[x] = ++dn;
  if (mx[x]) Dfs(mx[x], tp);
  for (int i = head[x]; i; i = e[i].next)
    if (e[i].to != mx[x]) Dfs(e[i].to, e[i].to);
  nr[x] = dn;
}
bool flag = 0;
struct Seg {
  struct Tree {
    int l, r, x, val, tag;
  } T[200000 * 4 + 5];
  void Build(int x, int l, int r) {
    if ((T[x].l = l) == (T[x].r = r)) {
      T[x].x = flag;
      return;
    }
    int mid = l + r >> 1;
    Build(x << 1, l, mid);
    Build(x << 1 | 1, mid + 1, r);
    T[x].x = (T[x << 1].x + T[x << 1 | 1].x) % 1000000007;
  }
  inline void Mark(int x, int v) {
    if (!T[x].tag) T[x].tag = T[x].val = 1;
    T[x].val = 1LL * T[x].val * v % 1000000007;
    T[x].x = 1LL * T[x].x * v % 1000000007;
  }
  inline void pushdown(int x) {
    Mark(x << 1, T[x].val);
    Mark(x << 1 | 1, T[x].val);
    T[x].tag = 0;
  }
  void Modify(int x, int k, int v) {
    if (T[x].l == T[x].r) {
      T[x].x = v;
      return;
    }
    int mid = T[x].l + T[x].r >> 1;
    if (T[x].tag) pushdown(x);
    Modify(x << 1 | (k > mid), k, v);
    T[x].x = (T[x << 1].x + T[x << 1 | 1].x) % 1000000007;
  }
  void Modify(int x, int l, int r, int v) {
    if (T[x].l == l && T[x].r == r) {
      Mark(x, v);
      return;
    }
    int mid = T[x].l + T[x].r >> 1;
    if (T[x].tag) pushdown(x);
    if (r <= mid)
      Modify(x << 1, l, r, v);
    else if (l > mid)
      Modify(x << 1 | 1, l, r, v);
    else
      Modify(x << 1, l, mid, v), Modify(x << 1 | 1, mid + 1, r, v);
    T[x].x = (T[x << 1].x + T[x << 1 | 1].x) % 1000000007;
  }
  int Query(int x, int l, int r) {
    if (T[x].l == l && r == T[x].r) return T[x].x;
    int mid = T[x].l + T[x].r >> 1;
    if (T[x].tag) pushdown(x);
    if (r <= mid)
      return Query(x << 1, l, r);
    else if (l > mid)
      return Query(x << 1 | 1, l, r);
    else
      return (Query(x << 1, l, mid) + Query(x << 1 | 1, mid + 1, r)) %
             1000000007;
  }
} s, S;
int pow(int x, int k) {
  int sum = 1;
  for (; k; k >>= 1, x = 1LL * x * x % 1000000007)
    if (k & 1) sum = 1LL * sum * x % 1000000007;
  return sum;
}
int main() {
  v[0] = read();
  Q = read();
  inv[0] = inv[1] = 1;
  for (int i = 2; i <= 200000; ++i)
    inv[i] =
        1LL * (1000000007 - 1000000007 / i) * inv[1000000007 % i] % 1000000007;
  for (int i = 1; i <= Q; ++i)
    if (read() == 1)
      p[i] = read(), v[i] = read(), ins(p[i], ++tot), p[i] = tot;
    else
      v[i] = read();
  Pre(1);
  Dfs(1, 1);
  s.Build(1, 1, tot);
  flag = 1;
  S.Build(1, 1, tot);
  s.Modify(son[1] = 1, 1, v[0]);
  for (int i = 1; i <= Q; ++i)
    if (!p[i]) {
      int x = v[i] == 1 ? 1 : S.Query(1, nl[fa[v[i]]], nl[fa[v[i]]]);
      printf("%d\n", 1LL * pow(x, 1000000007 - 2) *
                         s.Query(1, nl[v[i]], nr[v[i]]) % 1000000007);
    } else {
      int k = 1LL * inv[son[fa[p[i]]]] * (son[fa[p[i]]] + 1) % 1000000007;
      ++son[fa[p[i]]];
      s.Modify(1, nl[fa[p[i]]], nr[fa[p[i]]], k);
      S.Modify(1, nl[fa[p[i]]], nr[fa[p[i]]], k);
      s.Modify(
          1, nl[p[i]],
          1LL * v[i] * S.Query(1, nl[fa[p[i]]], nl[fa[p[i]]]) % 1000000007);
      son[p[i]] = 1;
    }
  return 0;
}