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 double pi =
    3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862;
void gn(int &x) {
  int sg = 1;
  char c;
  while (((c = getchar()) < '0' || c > '9') && c != '-')
    ;
  if (c == '-')
    sg = -1, x = 0;
  else
    x = c - '0';
  while ((c = getchar()) >= '0' && c <= '9') x = x * 10 + c - '0';
  x *= sg;
}
void gn(long long &x) {
  int sg = 1;
  char c;
  while (((c = getchar()) < '0' || c > '9') && c != '-')
    ;
  if (c == '-')
    sg = -1, x = 0;
  else
    x = c - '0';
  while ((c = getchar()) >= '0' && c <= '9') x = x * 10 + c - '0';
  x *= sg;
}
int mo = 1000000007;
int inf = 1061109567;
double eps = 1e-6;
int qp(int a, long long b) {
  int ans = 1;
  do {
    if (b & 1) ans = 1ll * ans * a % mo;
    a = 1ll * a * a % mo;
  } while (b >>= 1);
  return ans;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
struct edge {
  int v, next;
} e[222222];
int etot = 0;
int g[222222];
void ae(int u, int v) {
  e[etot].v = v;
  e[etot].next = g[u];
  g[u] = etot++;
}
struct que {
  int opt, u, v, id;
} qu[222222];
int v1, q;
int n;
int lef[222222], rig[222222];
int ind = 0;
int dfn[222222], rdfn[222222];
int ind2 = 0;
void dfs(int u) {
  lef[u] = ++ind;
  dfn[u] = ++ind2;
  for (int i = g[u]; ~i; i = e[i].next) dfs(e[i].v);
  rig[u] = ++ind;
  rdfn[u] = ind2;
}
int bit[444444];
void bitupd(int x, int d) {
  for (; x <= 2 * n; x += x & -x) bit[x] = 1ll * bit[x] * d % mo;
}
int bitque(int x) {
  int ans = 1;
  for (; x; x -= x & -x) ans = 1ll * ans * bit[x] % mo;
  return ans;
}
int sz[222222];
int seg[888888], tag[888888];
int l1, r1, d;
void build(int l, int r, int x) {
  tag[x] = 1;
  if (l != r) {
    int mid = l + r >> 1;
    build(l, mid, x << 1);
    build(mid + 1, r, x << 1 | 1);
  }
}
void pd(int x) {
  seg[x << 1] = 1ll * seg[x << 1] * tag[x] % mo;
  seg[x << 1 | 1] = 1ll * seg[x << 1 | 1] * tag[x] % mo;
  tag[x << 1] = 1ll * tag[x << 1] * tag[x] % mo;
  tag[x << 1 | 1] = 1ll * tag[x << 1 | 1] * tag[x] % mo;
  tag[x] = 1;
}
void segupd(int l, int r, int x) {
  if (l1 <= l && r <= r1) {
    seg[x] = 1ll * seg[x] * d % mo;
    tag[x] = 1ll * tag[x] * d % mo;
  } else {
    int mid = l + r >> 1;
    if (tag[x] != 1) pd(x);
    if (l1 <= mid) segupd(l, mid, x << 1);
    if (r1 > mid) segupd(mid + 1, r, x << 1 | 1);
    seg[x] = (seg[x << 1] + seg[x << 1 | 1]) % mo;
  }
}
int I;
void segupd1(int l, int r, int x) {
  if (l == r) {
    seg[x] = d;
  } else {
    int mid = l + r >> 1;
    if (tag[x] != 1) pd(x);
    if (I <= mid)
      segupd1(l, mid, x << 1);
    else
      segupd1(mid + 1, r, x << 1 | 1);
    seg[x] = (seg[x << 1] + seg[x << 1 | 1]) % mo;
  }
}
void segque(int l, int r, int x) {
  if (l1 <= l && r <= r1) {
    d = (d + seg[x]) % mo;
  } else {
    int mid = l + r >> 1;
    if (tag[x] != 1) pd(x);
    if (l1 <= mid) segque(l, mid, x << 1);
    if (r1 > mid) segque(mid + 1, r, x << 1 | 1);
  }
}
void updsz(int u, int del) {
  bitupd(lef[u], del);
  bitupd(rig[u], qp(del, mo - 2));
  d = del;
  l1 = dfn[u], r1 = rdfn[u];
  segupd(1, n, 1);
  sz[u]++;
}
int main() {
  memset(g, -1, sizeof(g));
  gn(v1);
  gn(q);
  n = 1;
  for (int i = 1; i <= q; i++) {
    gn(qu[i].opt);
    if (qu[i].opt == 1) {
      gn(qu[i].u);
      gn(qu[i].v);
      qu[i].id = ++n;
      ae(qu[i].u, n);
    } else
      gn(qu[i].u);
  }
  dfs(1);
  for (int i = 1; i <= n; i++) sz[i] = 1;
  for (int i = 1; i <= 2 * n; i++) bit[i] = 1;
  build(1, n, 1);
  I = 1, d = v1;
  segupd1(1, n, 1);
  for (int i = 1; i <= q; i++) {
    if (qu[i].opt == 1) {
      int del = 1ll * (sz[qu[i].u] + 1) * qp(sz[qu[i].u], mo - 2) % mo;
      updsz(qu[i].u, del);
      I = dfn[qu[i].id];
      d = 1ll * bitque(lef[qu[i].u]) * qu[i].v % mo;
      segupd1(1, n, 1);
    } else {
      l1 = dfn[qu[i].u], r1 = rdfn[qu[i].u];
      d = 0;
      segque(1, n, 1);
      int x = 1ll * sz[qu[i].u] * qp(bitque(lef[qu[i].u]), mo - 2) % mo;
      x = 1ll * x * d % mo;
      printf("%d\n", x);
    }
  }
  return 0;
}