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;
int ri() {
  int x;
  scanf("%d", &x);
  return x;
}
const int N = 200001, NN = 262144, MOD = 1000000007;
int val[N], deg[N], par[N], pre[N], post[N], tick;
long long sum[2 * NN], mul[NN], tag[2 * NN];
pair<int, int> a[N];
vector<int> es[N];
void dfs(int u) {
  pre[u] = tick++;
  for (int v : es[u]) dfs(v);
  post[u] = tick;
}
void apply(int i, long long x) {
  sum[i] = sum[i] * x % MOD;
  if (NN <= i) mul[i - NN] = mul[i - NN] * x % MOD;
  tag[i] = tag[i] * x % MOD;
}
void mconcat(int i) { sum[i] = (sum[2 * i] + sum[2 * i + 1]) % MOD; }
void untag(int i) {
  if (i < 0 || NN <= i) return;
  i += NN;
  for (int j, h = 31 - __builtin_clz(NN); h; h--)
    if (tag[j = i >> h] != 1) {
      apply(2 * j, tag[j]);
      apply(2 * j + 1, tag[j]);
      tag[j] = 1;
    }
}
void multiply(int l, int r, long long x) {
  untag(l - 1);
  untag(r);
  bool lf = false, rf = false;
  long long s = 0;
  for (l += NN, r += NN; l < r;) {
    if (l & 1) lf = true, apply(l++, x);
    l >>= 1;
    if (lf) mconcat(l - 1);
    if (r & 1) rf = true, apply(--r, x);
    r >>= 1;
    if (rf) mconcat(r);
  }
  for (l--; l >>= 1, r >>= 1;) {
    if (lf || l == r) mconcat(l);
    if (rf && l != r) mconcat(r);
  }
}
void add(int i, long long x) {
  untag(i);
  i += NN;
  sum[i] = (sum[i] + x) % MOD;
  while (i >>= 1) mconcat(i);
}
long long getSum(int l, int r) {
  untag(l - 1);
  untag(r);
  long long s = 0;
  for (l += NN, r += NN; l < r; l >>= 1, r >>= 1) {
    if (l & 1) s = (s + sum[l++]) % MOD;
    if (r & 1) s = (s + sum[--r]) % MOD;
  }
  return s;
}
long long getMul(int i) {
  untag(i);
  return mul[i];
}
long long inv(long long x) {
  long long s = 1;
  for (; x > 1; x = MOD % x) s = s * (MOD - MOD / x) % MOD;
  return s;
}
int main() {
  val[0] = ri();
  int q = ri(), n = 1;
  for (int i = 0; i < (q); i++) {
    int op = ri(), x = ri() - 1;
    if (op == 1) {
      val[n] = ri();
      par[n] = x;
      es[x].push_back(n);
      a[i] = {op, n++};
    } else
      a[i] = {op, x};
  }
  dfs(0);
  fill_n(tag, 2 * NN, 1);
  add(pre[0], val[0]);
  mul[pre[0]] = 1;
  for (int i = 0; i < (q); i++) {
    int v = a[i].second;
    if (a[i].first == 1) {
      int u = par[v];
      deg[u]++;
      multiply(pre[u], post[u], (deg[u] + 1) * inv(deg[u]) % MOD);
      long long t = getMul(pre[u]);
      add(pre[v], val[v] * t % MOD);
      mul[pre[v]] = t;
    } else {
      long long t = getSum(pre[v], post[v]);
      if (v) t = t * (deg[v] + 1) % MOD * inv(getMul(pre[v])) % MOD;
      printf("%lld\n", t);
    }
  }
}