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>
long long inp() {
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  long long sum = 0;
  while (c >= '0' && c <= '9') {
    sum = sum * 10 + c - '0';
    c = getchar();
  }
  return sum;
}
long long head[200010], nxt[400010], end[400010], dfn[200010], num[200010],
    size[200010], cou = 0;
long long p[200010], pt[200010], fa[200010], v[200010], w[200010],
    size_f[200010], op[200010];
void link(long long a, long long b) {
  nxt[++cou] = head[a];
  head[a] = cou;
  end[cou] = b;
}
long long idx = 0;
void dfs(long long cur) {
  dfn[cur] = ++idx;
  num[idx] = cur;
  size_f[cur] = 1;
  for (long long x = head[cur]; x != -1; x = nxt[x]) {
    dfs(end[x]);
    size_f[cur] += size_f[end[x]];
  }
}
long long fpow(long long a, long long b) {
  long long sum = 1;
  for (; b; b >>= 1) {
    if (b & 1) {
      sum *= a;
      sum %= 1000000007;
    }
    a *= a;
    a %= 1000000007;
  }
  return sum;
}
long long v1;
struct SEG_Tree {
  struct SEG {
    long long l;
    long long r;
    long long lazy1;
    long long lazy2;
    long long sum;
  } t[1600010];
  void push_up(long long cur) {
    t[cur].sum = (t[((cur) << 1)].sum + t[((cur) << 1 | 1)].sum) % 1000000007;
  }
  void push_down(long long cur) {
    if (t[cur].lazy1 != 1) {
      t[((cur) << 1)].lazy1 *= t[cur].lazy1;
      t[((cur) << 1)].sum *= t[cur].lazy1;
      t[((cur) << 1 | 1)].lazy1 *= t[cur].lazy1;
      t[((cur) << 1 | 1)].sum *= t[cur].lazy1;
      t[((cur) << 1)].lazy1 %= 1000000007;
      t[((cur) << 1)].sum %= 1000000007;
      t[((cur) << 1 | 1)].lazy1 %= 1000000007;
      t[((cur) << 1 | 1)].sum %= 1000000007;
      t[cur].lazy1 = 1;
    }
  }
  void build(long long cur, long long l, long long r) {
    t[cur].l = l;
    t[cur].r = r;
    t[cur].sum = 0;
    t[cur].lazy1 = 1;
    if (l == r) {
      if (l == 1) t[cur].sum = v1;
      return;
    }
    long long mid = (l + r) >> 1;
    build(((cur) << 1), l, mid);
    build(((cur) << 1 | 1), mid + 1, r);
    push_up(cur);
  }
  long long query(long long cur, long long l, long long r) {
    if (t[cur].l > r || t[cur].r < l) return 0;
    if (t[cur].l >= l && t[cur].r <= r) return t[cur].sum;
    push_down(cur);
    return (query(((cur) << 1), l, r) + query(((cur) << 1 | 1), l, r)) %
           1000000007;
  }
  void modify(long long cur, long long l, long long r, long long c) {
    if (t[cur].l > r || t[cur].r < l) return;
    if (t[cur].l >= l && t[cur].r <= r) {
      t[cur].lazy1 *= c;
      t[cur].sum *= c;
      t[cur].lazy1 %= 1000000007;
      t[cur].sum %= 1000000007;
      return;
    }
    push_down(cur);
    modify(((cur) << 1), l, r, c);
    modify(((cur) << 1 | 1), l, r, c);
    push_up(cur);
  }
  void modify1(long long cur, long long id, long long c) {
    if (t[cur].l == t[cur].r) {
      t[cur].sum = c;
      return;
    }
    push_down(cur);
    if (id <= t[((cur) << 1)].r)
      modify1(((cur) << 1), id, c);
    else
      modify1(((cur) << 1 | 1), id, c);
    push_up(cur);
  }
} t1, t2;
signed main() {
  memset(head, -1, sizeof(head));
  v1 = inp();
  long long q = inp();
  long long n = 1;
  for (long long i = 1; i <= q; i++) {
    op[i] = inp();
    if (op[i] == 1) {
      p[i] = inp();
      link(p[i], ++n);
      pt[i] = n;
      fa[pt[i]] = p[i];
      w[n] = inp();
    } else
      v[i] = inp();
  }
  dfs(1);
  t1.build(1, 1, n);
  v1 = 1;
  t2.build(1, 1, n);
  size[1] = 1;
  for (long long i = 1; i <= q; i++) {
    if (op[i] == 1) {
      size[pt[i]] = 1;
      long long mul = (long long)(size[p[i]] + 1) *
                      (fpow(size[p[i]], 1000000007 - 2)) % 1000000007;
      t1.modify(1, dfn[p[i]], dfn[p[i]] + size_f[p[i]] - 1, mul);
      size[p[i]]++;
      t2.modify(1, dfn[p[i]], dfn[p[i]] + size_f[p[i]] - 1, mul);
      long long num = t2.query(1, dfn[p[i]], dfn[p[i]]);
      t1.modify1(1, dfn[pt[i]], w[pt[i]] * num % 1000000007);
      num = t2.query(1, dfn[p[i]], dfn[p[i]]);
      t2.modify1(1, dfn[pt[i]], num);
    } else {
      long long num = 1;
      if (v[i] != 1) num = t2.query(1, dfn[fa[v[i]]], dfn[fa[v[i]]]);
      long long ans = t1.query(1, dfn[v[i]], dfn[v[i]] + size_f[v[i]] - 1);
      printf("%lld\n", ans * (fpow(num, 1000000007 - 2)) % 1000000007);
    }
  }
}