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 MAXN = 2e5 + 10;
const long long MOD = 1e9 + 7;
long long n, q, par[MAXN], s_t[MAXN], f_t[MAXN], tm, que[MAXN];
long long sum[4 * MAXN], mul[4 * MAXN], val[MAXN], lz[4 * MAXN];
vector<long long> adj[MAXN];
void dfs(long long v) {
  s_t[v] = tm++;
  for (long long u : adj[v]) dfs(u);
  f_t[v] = tm;
}
long long pw(long long a, long long b) {
  long long ret = 1;
  while (b) {
    if (b & 1) ret = (ret * a) % MOD;
    b >>= 1;
    a = (a * a) % MOD;
  }
  return ret;
}
void plant(long long v, long long b, long long e) {
  lz[v] = 1;
  if (e - b == 1) {
    if (b == 0) sum[v] = val[0], mul[v] = 1;
    return;
  }
  long long mid = (b + e) / 2;
  plant(v << 1, b, mid);
  plant(v << 1 ^ 1, mid, e);
  sum[v] = (sum[v << 1] + sum[v << 1 ^ 1]) % MOD;
}
void absorb(long long v) {
  mul[v << 1] = (mul[v << 1] * lz[v]) % MOD;
  mul[v << 1 ^ 1] = (mul[v << 1 ^ 1] * lz[v]) % MOD;
  sum[v << 1] = (sum[v << 1] * lz[v]) % MOD;
  sum[v << 1 ^ 1] = (sum[v << 1 ^ 1] * lz[v]) % MOD;
  lz[v << 1] = (lz[v << 1] * lz[v]) % MOD;
  lz[v << 1 ^ 1] = (lz[v << 1 ^ 1] * lz[v]) % MOD;
  lz[v] = 1;
}
void asg(long long v, long long b, long long e, long long x, long long sm,
         long long ml) {
  if (e - b == 1) {
    sum[v] = (sm * ml) % MOD, mul[v] = ml;
    return;
  }
  long long mid = (b + e) / 2;
  absorb(v);
  if (x < mid)
    asg(v << 1, b, mid, x, sm, ml);
  else
    asg(v << 1 ^ 1, mid, e, x, sm, ml);
  sum[v] = (sum[v << 1] + sum[v << 1 ^ 1]) % MOD;
}
void water(long long v, long long b, long long e, long long l, long long r,
           long long m) {
  if (l <= b && e <= r) {
    lz[v] = (lz[v] * m) % MOD;
    sum[v] = (sum[v] * m) % MOD;
    mul[v] = (mul[v] * m) % MOD;
    return;
  }
  if (r <= b || e <= l) return;
  long long mid = (b + e) / 2;
  absorb(v);
  water(v << 1, b, mid, l, r, m);
  water(v << 1 ^ 1, mid, e, l, r, m);
  sum[v] = (sum[v << 1] + sum[v << 1 ^ 1]) % MOD;
}
long long get_mul(long long v, long long b, long long e, long long x) {
  if (e - b == 1) return mul[v];
  long long mid = (b + e) / 2;
  absorb(v);
  if (x < mid) return get_mul(v << 1, b, mid, x);
  return get_mul(v << 1 ^ 1, mid, e, x);
}
long long get_sum(long long v, long long b, long long e, long long l,
                  long long r) {
  if (l <= b && e <= r) return sum[v];
  if (r <= b || e <= l) return 0;
  long long mid = (b + e) / 2;
  absorb(v);
  return (get_sum(v << 1, b, mid, l, r) + get_sum(v << 1 ^ 1, mid, e, l, r)) %
         MOD;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> val[n++] >> q;
  for (long long i = 0; i < q; i++) {
    long long type;
    cin >> type;
    if (type == 1) {
      cin >> par[n] >> val[n];
      par[n]--;
      par[n] = par[n];
      adj[par[n]].push_back(n);
      n++;
    } else
      cin >> que[i];
  }
  dfs(0);
  plant(1, 0, n);
  for (long long i = 0; i < n; i++) adj[i].clear();
  long long c = 1;
  for (long long i = 0; i < q; i++) {
    if (que[i] == 0) {
      long long tt = adj[par[c]].size();
      long long m = ((tt + 2) * pw(tt + 1, MOD - 2)) % MOD;
      water(1, 0, n, s_t[par[c]], f_t[par[c]], m);
      asg(1, 0, n, s_t[c], val[c], get_mul(1, 0, n, s_t[par[c]]));
      adj[par[c]].push_back(c);
      c++;
    } else {
      long long v = que[i] - 1;
      if (v == 0)
        cout << get_sum(1, 0, n, s_t[v], f_t[v]) << "\n";
      else
        cout << (get_sum(1, 0, n, s_t[v], f_t[v]) *
                 pw(get_mul(1, 0, n, s_t[par[v]]), MOD - 2)) %
                    MOD
             << "\n";
    }
  }
  return 0;
}