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;
const int N = 1514514;
const int mod = 1e9 + 7;
vector<int> v[N], q[N];
int fa[N], sz[N], d[N];
int n, m, pos, as[N];
long long tr[N], s[N], lz[N], w[N];
long long msk(long long a) {
  long long b = mod - 2, k = 1;
  while (b) {
    if (b & 1) k = k * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return k;
}
void down(int i) {
  long long k = lz[i];
  lz[i] = 1;
  if (k <= 1) return;
  lz[(i << 1)] = lz[(i << 1)] * k % mod;
  lz[(i << 1 | 1)] = lz[(i << 1 | 1)] * k % mod;
  tr[(i << 1)] = tr[(i << 1)] * k % mod;
  tr[(i << 1 | 1)] = tr[(i << 1 | 1)] * k % mod;
}
void add(int i, int l, int r, int s, int t, long long w1, long long w2) {
  if (s <= l && r <= t) {
    tr[i] = (tr[i] + w1) * w2 % mod;
    lz[i] = lz[i] * w2 % mod;
    return;
  }
  down(i);
  if (s <= ((l + r) >> 1)) add((i << 1), l, ((l + r) >> 1), s, t, w1, w2);
  if (t > ((l + r) >> 1))
    add((i << 1 | 1), ((l + r) >> 1) + 1, r, s, t, w1, w2);
  tr[i] = (tr[(i << 1)] + tr[(i << 1 | 1)]) % mod;
}
void dfs(int x) {
  d[x] = ++pos;
  sz[x] = 1;
  for (int i = 0; i < v[x].size(); i++) dfs(v[x][i]), sz[x] += sz[v[x][i]];
}
long long query(int i, int l, int r, int s, int t) {
  if (s <= l && r <= t) return tr[i];
  down(i);
  long long ans = 0;
  if (s <= ((l + r) >> 1)) ans = query((i << 1), l, ((l + r) >> 1), s, t);
  if (t > ((l + r) >> 1))
    ans = (ans + query((i << 1 | 1), ((l + r) >> 1) + 1, r, s, t)) % mod;
  return ans;
}
int main() {
  scanf("%d%d", &w[1], &m);
  n = 1;
  for (int i = 1, op, x; i <= m; i++) {
    scanf("%d%d", &op, &x);
    if (op == 1)
      n++, scanf("%d", &w[n]), fa[n] = x, v[x].push_back(n);
    else
      q[n].push_back(x);
  }
  dfs(1);
  add(1, 1, n, 1, 1, w[1], 1);
  s[1] = 1;
  for (int j = 0; j < q[1].size(); j++) printf("%lld\n", w[1]);
  for (int i = (2); i <= (n); i++) {
    int f = fa[i];
    add(1, 1, n, d[f], d[f] + sz[f] - 1, 0, (s[f] + 1) * msk(s[f]) % mod);
    s[f]++;
    s[i] = 1;
    add(1, 1, n, d[i], d[i],
        query(1, 1, n, d[f], d[f]) * msk(w[f]) % mod * w[i] % mod, 1);
    for (int j = 0; j < q[i].size(); j++) {
      int u = q[i][j];
      long long kkr = query(1, 1, n, d[u], d[u] + sz[u] - 1);
      if (u == 1)
        printf("%lld\n", kkr);
      else
        printf("%lld\n", kkr * w[fa[u]] % mod *
                             msk(query(1, 1, n, d[fa[u]], d[fa[u]])) % mod);
    }
  }
}