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 = 2e5 + 6;
const int MOD = 1e9 + 7;
int n, q;
int Time;
int V[N];
int cmd[N], node[N];
int nChild[N];
vector<int> child[N];
int L[N], R[N];
void dfs(int u) {
  L[u] = ++Time;
  for (int v : child[u]) {
    dfs(v);
  }
  R[u] = Time;
}
void add(int &a, int b) {
  a += b;
  if (a >= MOD) a -= MOD;
}
int power(long long x, int p) {
  long long ans = 1;
  for (; p; p >>= 1) {
    if (p & 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}
int inverse(int x) { return power(x, MOD - 2); }
struct Node {
  int l, r;
  int sum, mul;
  Node *left, *right;
  Node(int l, int r, int v = 0)
      : l(l), r(r), sum(v * (r - l + 1)), mul(1), left(NULL), right(NULL) {}
  void pushDown() {
    if (mul != 1) {
      sum = 1LL * sum * mul % MOD;
      if (l < r) {
        left->mul = 1LL * left->mul * mul % MOD;
        right->mul = 1LL * right->mul * mul % MOD;
      }
      mul = 1;
    }
  }
  void gather() {
    sum = left->sum + right->sum;
    if (sum >= MOD) sum -= MOD;
  }
  void update(int i, int v) {
    pushDown();
    if (r < i || i < l) return;
    if (l == r) {
      sum = v;
      mul = 1;
      return;
    }
    left->update(i, v);
    right->update(i, v);
    gather();
  }
  void scaleRange(int i, int j, int v) {
    pushDown();
    if (r < i || j < l) return;
    if (i <= l && r <= j) {
      mul = 1LL * mul * v % MOD;
      pushDown();
      return;
    }
    left->scaleRange(i, j, v);
    right->scaleRange(i, j, v);
    gather();
  }
  int sumRange(int i, int j) {
    pushDown();
    if (r < i || j < l) return 0;
    if (i <= l && r <= j) return sum;
    return (left->sumRange(i, j) + right->sumRange(i, j)) % MOD;
  }
  int valueAt(int i) { return sumRange(i, i); }
};
Node *build(int l, int r, int v = 0) {
  Node *x = new Node(l, r, v);
  if (l == r) return x;
  x->left = build(l, l + r >> 1, v);
  x->right = build((l + r >> 1) + 1, r, v);
  return x;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> V[1] >> q;
  int curIndex = 1;
  for (int i = 1; i <= q; ++i) {
    cin >> cmd[i] >> node[i];
    if (cmd[i] == 1) cin >> V[++curIndex];
  }
  curIndex = 1;
  for (int i = 1; i <= q; ++i)
    if (cmd[i] == 1) child[node[i]].push_back(++curIndex);
  int n = curIndex;
  dfs(1);
  Node *root = build(1, n);
  Node *cnt = build(1, n, 1);
  root->update(L[1], V[1]);
  curIndex = 1;
  for (int i = 1; i <= q; ++i) {
    if (cmd[i] == 1) {
      ++curIndex;
      int mul = ++nChild[node[i]];
      root->scaleRange(L[node[i]], R[node[i]],
                       1LL * (mul + 1) * inverse(mul) % MOD);
      cnt->scaleRange(L[node[i]], R[node[i]],
                      1LL * (mul + 1) * inverse(mul) % MOD);
      root->update(L[curIndex],
                   1LL * V[curIndex] * cnt->valueAt(L[curIndex]) % MOD);
    } else {
      cout << 1LL * root->sumRange(L[node[i]], R[node[i]]) *
                  (nChild[node[i]] + 1) % MOD *
                  inverse(cnt->valueAt(L[node[i]])) % MOD
           << '\n';
    }
  }
  return 0;
}