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 = 200005, P = 1000000007;
using ll = long long;
ll qpow(ll a, ll b) {
  ll ret = 1;
  while (b) {
    if (b & 1) ret = ret * a % P;
    a = a * a % P;
    b >>= 1;
  }
  return ret;
}
inline ll inv(ll num) { return qpow(num, P - 2); }
int v1, n, m, sz[N], s[N], a[N], idx[N], fa[N];
vector<int> v[N];
void dfs(int pos) {
  static int id = 0;
  idx[pos] = ++id;
  sz[pos] = 1;
  for (auto &i : v[pos]) fa[i] = pos, dfs(i), sz[pos] += sz[i];
}
struct Query {
  int op, pos;
} q[N];
struct TNode {
  int l, r;
  ll v;
} t[N << 2];
ll lazy[N << 2];
inline int lc(int pos) { return pos << 1; }
inline int rc(int pos) { return pos << 1 | 1; }
inline void pushup(int pos) { t[pos].v = (t[lc(pos)].v + t[rc(pos)].v) % P; }
void build(int pos, int l, int r) {
  t[pos].l = l;
  t[pos].r = r;
  lazy[pos] = 1;
  if (l == r) {
    if (l == 1) t[pos].v = a[1];
    return;
  }
  int mid = (l + r) >> 1;
  build(lc(pos), l, mid);
  build(rc(pos), mid + 1, r);
  pushup(pos);
}
inline void pushdown(int pos) {
  if (lazy[pos] == 1) return;
  t[lc(pos)].v = t[lc(pos)].v * lazy[pos] % P;
  lazy[lc(pos)] = lazy[lc(pos)] * lazy[pos] % P;
  t[rc(pos)].v = t[rc(pos)].v * lazy[pos] % P;
  lazy[rc(pos)] = lazy[rc(pos)] * lazy[pos] % P;
  lazy[pos] = 1;
}
void add(int pos, int mp, int v) {
  if (t[pos].l == t[pos].r) {
    t[pos].v = v;
    return;
  }
  pushdown(pos);
  int mid = (t[pos].l + t[pos].r) >> 1;
  if (mp <= mid)
    add(lc(pos), mp, v);
  else
    add(rc(pos), mp, v);
  pushup(pos);
}
void mul(int pos, int l, int r, int v) {
  if (t[pos].l == l && t[pos].r == r) {
    lazy[pos] = lazy[pos] * v % P;
    t[pos].v = t[pos].v * v % P;
    return;
  }
  pushdown(pos);
  int mid = (t[pos].l + t[pos].r) >> 1;
  if (r <= mid)
    mul(lc(pos), l, r, v);
  else if (l > mid)
    mul(rc(pos), l, r, v);
  else
    mul(lc(pos), l, mid, v), mul(rc(pos), mid + 1, r, v);
  pushup(pos);
}
ll query(int pos, int l, int r) {
  if (t[pos].l == l && t[pos].r == r) return t[pos].v;
  pushdown(pos);
  int mid = (t[pos].l + t[pos].r) >> 1;
  if (r <= mid)
    return query(lc(pos), l, r);
  else if (l > mid)
    return query(rc(pos), l, r);
  else
    return (query(lc(pos), l, mid) + query(rc(pos), mid + 1, r)) % P;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> a[1] >> m;
  n = 1;
  s[1] = 1;
  for (int i = 1; i <= m; i++) {
    cin >> q[i].op >> q[i].pos;
    if (q[i].op == 1) {
      cin >> a[++n];
      v[q[i].pos].push_back(n);
      q[i].pos = n;
    }
  }
  dfs(1);
  build(1, 1, n);
  for (int i = 1; i <= m; i++)
    if (q[i].op == 1) {
      int pos = q[i].pos, f = fa[pos];
      add(1, idx[pos], query(1, idx[f], idx[f]) * inv(a[f]) % P * a[pos] % P);
      mul(1, idx[f], idx[f] + sz[f] - 1, inv(s[f]) * (s[f] + 1) % P);
      s[pos] = 1;
      ++s[f];
    } else {
      int pos = q[i].pos, f = fa[pos];
      ll ans = query(1, idx[pos], idx[pos] + sz[pos] - 1);
      if (pos == 1) {
        cout << ans << endl;
        continue;
      }
      cout << ans * a[f] % P * inv(query(1, idx[f], idx[f])) % P << endl;
    }
  return 0;
}