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 maxq = 200005;
const int maxn = 200005;
const int maxm = 800005;
const int P = 1000000007;
int Q, N, h[maxn];
int qa[maxq], qb[maxq];
int ex[maxn], ey[maxn], enext[maxn], elast[maxn];
int fath[maxn], lid[maxn], rid[maxn], tot_id;
int card_s[maxn], cm[maxn];
int summ[maxm], lazy[maxm], pp, qq, rr;
inline int _qsm(int aa, int bb) {
  int cc = 1;
  while (bb > 0) {
    if (bb & 1) cc = 1ll * aa * cc % P;
    aa = 1ll * aa * aa % P;
    bb >>= 1;
  }
  return cc;
}
void _dfs(int u, int fa) {
  int j;
  fath[u] = fa;
  lid[u] = ++tot_id;
  for (j = elast[u]; j > 0; j = enext[j])
    if (ey[j] != fa) _dfs(ey[j], u);
  rid[u] = tot_id;
}
void _segment_pushup(int l, int r) {
  int i = (l + r) | (l != r);
  int ls = (l + ((l + r) >> 1)) | (l != ((l + r) >> 1));
  int rs = (((l + r) >> 1) + 1 + r) | (((l + r) >> 1) + 1 != r);
  summ[i] = summ[ls] + summ[rs];
  summ[i] -= summ[i] >= P ? P : 0;
}
void _segment_pushdown(int l, int r) {
  int i = (l + r) | (l != r);
  int ls = (l + ((l + r) >> 1)) | (l != ((l + r) >> 1));
  int rs = (((l + r) >> 1) + 1 + r) | (((l + r) >> 1) + 1 != r);
  int t = lazy[i];
  summ[ls] = 1ll * summ[ls] * t % P;
  lazy[ls] = 1ll * lazy[ls] * t % P;
  summ[rs] = 1ll * summ[rs] * t % P;
  lazy[rs] = 1ll * lazy[rs] * t % P;
  lazy[i] = 1;
}
void _segment_modify_mutl(int l, int r) {
  int i = (l + r) | (l != r);
  if (pp <= l && r <= qq) {
    summ[i] = 1ll * summ[i] * rr % P;
    lazy[i] = 1ll * lazy[i] * rr % P;
    return;
  }
  if (lazy[i] != 1) _segment_pushdown(l, r);
  if (pp <= ((l + r) >> 1)) _segment_modify_mutl(l, ((l + r) >> 1));
  if (qq > ((l + r) >> 1)) _segment_modify_mutl(((l + r) >> 1) + 1, r);
  _segment_pushup(l, r);
}
void _segment_modify_add(int l, int r) {
  int i = (l + r) | (l != r);
  if (pp <= l && r <= pp) {
    summ[i] += rr;
    summ[i] -= summ[i] >= P ? P : 0;
    return;
  }
  if (lazy[i] != 1) _segment_pushdown(l, r);
  if (pp <= ((l + r) >> 1)) _segment_modify_add(l, ((l + r) >> 1));
  if (pp > ((l + r) >> 1)) _segment_modify_add(((l + r) >> 1) + 1, r);
  _segment_pushup(l, r);
}
int _segment_query_sum(int l, int r) {
  int i = (l + r) | (l != r), t = 0;
  if (pp <= l && r <= qq) return summ[i];
  if (lazy[i] != 1) _segment_pushdown(l, r);
  if (pp <= ((l + r) >> 1)) t += _segment_query_sum(l, ((l + r) >> 1));
  if (qq > ((l + r) >> 1)) t += _segment_query_sum(((l + r) >> 1) + 1, r);
  t -= t >= P ? P : 0;
  return t;
}
void _1(int u) {
  int j, t, v;
  v = fath[u];
  card_s[u] = 1;
  card_s[v]++;
  pp = lid[v];
  qq = rid[v];
  rr = 1ll * _qsm(card_s[v] - 1, P - 2) * card_s[v] % P;
  _segment_modify_mutl(1, N);
  t = rr;
  for (j = lid[v]; j <= N; j += (j & (-j))) cm[j] = 1ll * cm[j] * t % P;
  t = _qsm(t, P - 2);
  for (j = rid[v]; j <= N; j += (j & (-j))) cm[j] = 1ll * cm[j] * t % P;
  t = 1;
  for (j = lid[u] - 1; j >= 1; j -= (j & (-j))) t = 1ll * t * cm[j] % P;
  t = 1ll * t * card_s[u] % P;
  pp = lid[u];
  rr = 1ll * t * h[u] % P;
  _segment_modify_add(1, N);
}
void _2(int u) {
  int j, t1, t2;
  t1 = 1;
  for (j = lid[u] - 1; j >= 1; j -= (j & (-j))) t1 = 1ll * t1 * cm[j] % P;
  t1 = _qsm(t1, P - 2);
  pp = lid[u];
  qq = rid[u];
  t2 = _segment_query_sum(1, N);
  t1 = 1ll * t1 * t2 % P;
  printf("%d\n", t1);
}
int main() {
  int i, j;
  scanf("%d%d", &h[1], &Q);
  N = 1;
  for (i = j = 1; i <= Q; i++) {
    scanf("%d", &qa[i]);
    if (qa[i] == 1) {
      scanf("%d", &qb[i]);
      scanf("%d", &h[++N]);
      ex[j] = qb[i];
      ey[j] = N;
      enext[j] = elast[ex[j]];
      elast[ex[j]] = j;
      j++;
    } else
      scanf("%d", &qb[i]);
  }
  _dfs(1, 0);
  card_s[1] = 1;
  for (j = 1; j <= N; j++) cm[j] = 1;
  for (j = 2; j <= (N << 1); j++) lazy[j] = 1;
  pp = 1;
  rr = h[1];
  _segment_modify_add(1, N);
  for (i = j = 1; i <= Q; i++) {
    if (qa[i] == 1)
      _1(++j);
    else
      _2(qb[i]);
  }
  return 0;
}