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 long long MXN = 2e5 + 10;
const long long MXS = MXN * 4;
const long long Mod = 1e9 + 7;
long long power(long long a, long long b) {
  return (!b ? 1 : power(a * a % Mod, b / 2) * (b & 1LL ? a : 1) % Mod);
}
long long inv(long long x) { return power(x, Mod - 2); }
long long n, k, q, timer, ans;
long long Val[MXN], Typ[MXN], A[MXN], B[MXN], Stm[MXN], Ftm[MXN], deg[MXN];
long long seg[MXS], Sum[MXS], LzSum[MXS], Zrb[MXS], LzZrb[MXS];
vector<long long> adj[MXN];
void Build(long long id = 1, long long s = 1, long long e = n) {
  Zrb[id] = LzZrb[id] = 1;
  if ((e - s + 1) == 1) return;
  Build((id * 2), s, ((s + e) / 2)), Build((id * 2 + 1), ((s + e) / 2 + 1), e);
}
void Shift(long long id, long long s, long long e) {
  if (LzZrb[id] == 1 && LzSum[id] == 0) return;
  if ((e - s + 1) == 1) {
    Zrb[id] = Zrb[id] * LzZrb[id] % Mod;
    Sum[id] = (Sum[id] + LzSum[id]) % Mod;
    seg[id] = Sum[id] * Zrb[id] % Mod;
    LzZrb[id] = 1, LzSum[id] = 0;
    return;
  }
  seg[id] = seg[id] * LzZrb[id] % Mod;
  LzZrb[(id * 2)] = LzZrb[(id * 2)] * LzZrb[id] % Mod;
  LzZrb[(id * 2 + 1)] = LzZrb[(id * 2 + 1)] * LzZrb[id] % Mod;
  LzSum[(id * 2)] = (LzSum[(id * 2)] + LzSum[id]) % Mod;
  LzSum[(id * 2 + 1)] = (LzSum[(id * 2 + 1)] + LzSum[id]) % Mod;
  LzZrb[id] = 1, LzSum[id] = 0;
}
void Upd(long long l, long long r, long long sm, long long zrb,
         long long id = 1, long long s = 1, long long e = n) {
  Shift(id, s, e);
  if (e < l || s > r) return;
  if (l <= s && e <= r) {
    LzZrb[id] = zrb, LzSum[id] = sm;
    Shift(id, s, e);
    return;
  }
  Upd(l, r, sm, zrb, (id * 2), s, ((s + e) / 2)),
      Upd(l, r, sm, zrb, (id * 2 + 1), ((s + e) / 2 + 1), e);
  seg[id] = (seg[(id * 2)] + seg[(id * 2 + 1)]) % Mod;
}
long long Get(long long l, long long r, long long id = 1, long long s = 1,
              long long e = n) {
  Shift(id, s, e);
  if (e < l || s > r) return 0;
  if (l <= s && e <= r) return seg[id];
  long long now = (Get(l, r, (id * 2), s, ((s + e) / 2)) +
                   Get(l, r, (id * 2 + 1), ((s + e) / 2 + 1), e)) %
                  Mod;
  seg[id] = (seg[(id * 2)] + seg[(id * 2 + 1)]) % Mod;
  return now;
}
long long Gtz(long long ind, long long id = 1, long long s = 1,
              long long e = n) {
  Shift(id, s, e);
  if (e < ind || s > ind) return 1;
  if ((e - s + 1) == 1) return Zrb[id];
  long long now = Gtz(ind, (id * 2), s, ((s + e) / 2)) *
                  Gtz(ind, (id * 2 + 1), ((s + e) / 2 + 1), e);
  seg[id] = (seg[(id * 2)] + seg[(id * 2 + 1)]) % Mod;
  return now;
}
void dfs(long long u, long long par) {
  timer++, Stm[u] = timer;
  for (auto v : adj[u]) {
    if (v == par) continue;
    dfs(v, u);
  }
  Ftm[u] = timer;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> Val[1] >> q;
  n++;
  for (int i = 1; i <= q; i++) {
    cin >> Typ[i] >> A[i];
    if (Typ[i] == 1) {
      cin >> B[i];
      n++;
      Val[n] = B[i];
      adj[n].push_back(A[i]), adj[A[i]].push_back(n);
    }
  }
  dfs(1, 0);
  Build();
  k++;
  Upd(Stm[1], Stm[1], Val[1], 1);
  for (int i = 1; i <= q; i++) {
    if (Typ[i] == 1) {
      k++;
      Upd(Stm[k], Stm[k], Val[k], 1);
      Upd(Stm[A[i]], Ftm[A[i]], 0, inv(deg[A[i]] + 1));
      deg[A[i]]++;
      Upd(Stm[A[i]], Ftm[A[i]], 0, deg[A[i]] + 1);
      continue;
    }
    ans = Gtz(Stm[A[i]]);
    ans = inv(ans);
    ans = ans * Get(Stm[A[i]], Ftm[A[i]]) % Mod;
    cout << ans * (deg[A[i]] + 1) % Mod << '\n';
  }
  return 0;
}