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 = 200100;
const long long mod = 1000000007;
long long segtree[N << 2], bl[N << 2], lazy[N << 2];
int fa[N], val[N], now = 1, id[N], to[N], tot = 2, q, sz[N];
struct ope {
  int xz, poi;
};
vector<ope> Q;
vector<int> son[N];
void dfs(int node) {
  id[node] = now++;
  for (int i = 0; i < son[node].size(); i++) dfs(son[node][i]);
  to[node] = now - 1;
}
long long pow_mod(long long a, long long b) {
  long long ret = 1;
  while (b) {
    if (b & 1) ret = (ret * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return ret;
}
long long Fermat(long long a) { return pow_mod(a, mod - 2); }
void chang(long long &a, long long b) {
  a *= b;
  a %= mod;
}
void pushdown(int l, int r, int rt) {
  if (lazy[rt] != 1) {
    chang(segtree[rt << 1], lazy[rt]);
    chang(segtree[rt << 1 | 1], lazy[rt]);
    chang(lazy[rt << 1], lazy[rt]);
    chang(lazy[rt << 1 | 1], lazy[rt]);
    chang(bl[rt << 1], lazy[rt]);
    chang(bl[rt << 1 | 1], lazy[rt]);
    lazy[rt] = 1;
  }
}
void pushup(int l, int r, int rt) {
  segtree[rt] = segtree[rt << 1] + segtree[rt << 1 | 1];
  segtree[rt] %= mod;
}
void build(int l, int r, int rt) {
  if (l == r) {
    bl[rt] = 1;
    lazy[rt] = 1;
    if (l == 1)
      segtree[rt] = val[1];
    else
      segtree[rt] = 0;
    return;
  }
  int m = (l + r) / 2;
  build(l, m, rt << 1);
  build(m + 1, r, rt << 1 | 1);
  bl[rt] = 1;
  lazy[rt] = 1;
  pushup(l, r, rt);
}
void add(int L, int R, long long v, long long w, int l, int r, int rt) {
  if (L <= l && R >= r) {
    chang(bl[rt], v);
    chang(bl[rt], w);
    chang(lazy[rt], v);
    chang(lazy[rt], w);
    chang(segtree[rt], v);
    chang(segtree[rt], w);
    return;
  }
  pushdown(l, r, rt);
  int m = (l + r) / 2;
  if (L <= m) add(L, R, v, w, l, m, rt << 1);
  if (R > m) add(L, R, v, w, m + 1, r, rt << 1 | 1);
  pushup(l, r, rt);
}
void update(int p, int v, int l, int r, int rt) {
  if (l == r) {
    segtree[rt] = v * bl[rt];
    segtree[rt] %= mod;
    return;
  }
  pushdown(l, r, rt);
  int m = (l + r) / 2;
  if (p <= m)
    update(p, v, l, m, rt << 1);
  else
    update(p, v, m + 1, r, rt << 1 | 1);
  pushup(l, r, rt);
}
long long querybl(int p, int l, int r, int rt) {
  if (l == r) return bl[rt];
  pushdown(l, r, rt);
  int m = (l + r) / 2;
  long long ans = 0;
  if (p <= m)
    ans = querybl(p, l, m, rt << 1);
  else
    ans = querybl(p, m + 1, r, rt << 1 | 1);
  pushup(l, r, rt);
  return ans;
}
long long query(int L, int R, int l, int r, int rt) {
  if (L <= l && R >= r) {
    return segtree[rt];
  }
  pushdown(l, r, rt);
  int m = (l + r) / 2;
  long long ans = 0;
  if (L <= m) ans += query(L, R, l, m, rt << 1);
  if (R > m) ans += query(L, R, m + 1, r, rt << 1 | 1);
  pushup(l, r, rt);
  ans %= mod;
  return ans;
}
int main() {
  scanf("%d%d", &val[1], &q);
  while (q--) {
    int ta, tb, tc;
    scanf("%d", &ta);
    if (ta == 1) {
      scanf("%d%d", &tb, &tc);
      son[tb].push_back(tot);
      fa[tot] = tb;
      val[tot] = tc;
      Q.push_back({1, tot++});
    } else {
      scanf("%d", &tb);
      Q.push_back({2, tb});
    }
  }
  fa[1] = 1;
  sz[1] = 1;
  tot--;
  dfs(1);
  build(1, tot, 1);
  for (int i = 0; i < Q.size(); i++) {
    if (Q[i].xz == 1) {
      int faq = fa[Q[i].poi];
      long long ny = Fermat(sz[faq]);
      update(id[Q[i].poi], val[Q[i].poi], 1, tot, 1);
      add(id[faq], to[faq], ny, sz[faq] + 1, 1, tot, 1);
      sz[faq]++;
      sz[Q[i].poi]++;
    } else {
      long long ny;
      if (Q[i].poi == 1)
        ny = 1;
      else
        ny = Fermat(querybl(id[fa[Q[i].poi]], 1, tot, 1));
      long long ans = query(id[Q[i].poi], to[Q[i].poi], 1, tot, 1);
      chang(ans, ny);
      printf("%lld\n", ans);
    }
  }
}