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 + 7;
const long long MOD = 1e9 + 7.1;
int v[N];
struct node {
  int type, x;
} query[N];
vector<int> G[N];
int in[N], out[N], len;
void dfs(int x) {
  ++len;
  in[x] = len;
  for (int v : G[x]) {
    dfs(v);
  }
  out[x] = len;
}
long long deg[N];
struct Tnode {
  long long m, mv, tag;
} T[N << 2];
long long inv(long long x) {
  int p = MOD - 2;
  long long ret = 1;
  while (p) {
    if (p & 1) {
      ret = ret * x % MOD;
    }
    x = x * x % MOD;
    p >>= 1;
  }
  return ret;
}
void build(int l, int r, int rt) {
  T[rt].mv = 0;
  T[rt].m = T[rt].tag = 1;
  if (l == r) return;
  int mid = l + r >> 1;
  build(l, mid, rt << 1);
  build(mid + 1, r, rt << 1 | 1);
}
void pushup(int rt) { T[rt].mv = (T[rt << 1].mv + T[rt << 1 | 1].mv) % MOD; }
void pushdown(int rt) {
  T[rt << 1].m = T[rt << 1].m * T[rt].tag % MOD;
  T[rt << 1].mv = T[rt << 1].mv * T[rt].tag % MOD;
  T[rt << 1].tag = T[rt << 1].tag * T[rt].tag % MOD;
  T[rt << 1 | 1].m = T[rt << 1 | 1].m * T[rt].tag % MOD;
  T[rt << 1 | 1].mv = T[rt << 1 | 1].mv * T[rt].tag % MOD;
  T[rt << 1 | 1].tag = T[rt << 1 | 1].tag * T[rt].tag % MOD;
  T[rt].tag = 1;
}
void upd(int L, int R, long long val, int l, int r, int rt) {
  if (L <= l && r <= R) {
    T[rt].tag = T[rt].tag * val % MOD;
    T[rt].m = T[rt].m * val % MOD;
    T[rt].mv = T[rt].mv * val % MOD;
    return;
  }
  pushdown(rt);
  int mid = l + r >> 1;
  if (L <= mid) upd(L, R, val, l, mid, rt << 1);
  if (mid < R) upd(L, R, val, mid + 1, r, rt << 1 | 1);
  pushup(rt);
}
void upd(int x, long long val, int l, int r, int rt) {
  if (l == r && l == x) {
    T[rt].mv = T[rt].m * val % MOD;
    return;
  }
  pushdown(rt);
  int mid = l + r >> 1;
  if (x <= mid)
    upd(x, val, l, mid, rt << 1);
  else
    upd(x, val, mid + 1, r, rt << 1 | 1);
  pushup(rt);
}
long long qry(int L, int R, int l, int r, int rt) {
  long long ret = 0;
  if (L <= l && r <= R) {
    return T[rt].mv;
  }
  pushdown(rt);
  int mid = l + r >> 1;
  if (L <= mid) ret = (ret + qry(L, R, l, mid, rt << 1)) % MOD;
  if (mid < R) ret = (ret + qry(L, R, mid + 1, r, rt << 1 | 1)) % MOD;
  return ret;
}
long long qry(int x, int l, int r, int rt) {
  if (l == r && l == x) {
    return T[rt].m;
  }
  pushdown(rt);
  int mid = l + r >> 1;
  if (x <= mid) return qry(x, l, mid, rt << 1);
  return qry(x, mid + 1, r, rt << 1 | 1);
}
int main() {
  int q, type, x, y, tot = 1;
  scanf("%d%d", &v[1], &q);
  for (int i = 0; i < q; ++i) {
    scanf("%d%d", &query[i].type, &query[i].x);
    if (query[i].type == 1) {
      G[query[i].x].push_back(++tot);
      scanf("%d", &v[tot]);
    }
  }
  len = 0;
  dfs(1);
  build(1, len, 1);
  tot = 1;
  upd(in[1], v[1], 1, len, 1);
  for (int i = 0; i < q; ++i) {
    int x = query[i].x;
    if (query[i].type == 1) {
      ++deg[x];
      long long p = (deg[x] + 1) * inv(deg[x]) % MOD;
      upd(in[x], out[x], p, 1, len, 1);
      ++tot;
      upd(in[tot], v[tot], 1, len, 1);
    } else {
      long long ans = qry(in[x], out[x], 1, len, 1);
      long long div = qry(in[x], 1, len, 1);
      ans = ans * (deg[x] + 1) % MOD * inv(div) % MOD;
      printf("%d\n", (int)ans);
    }
  }
  return 0;
}