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>
const int maxn = 2e5 + 3, lo = 0x40000;
const long long mo = 1e9 + 7;
int q, n, val[maxn], chi[maxn], par[maxn], lab[maxn], llab[maxn], rlab[maxn];
long long exgcd(const long long &a, const long long &b, long long &x,
                long long &y) {
  if (!a) {
    x = 0;
    y = 1;
    return b;
  }
  long long d = exgcd(b % a, a, y, x);
  x -= b / a * y;
  return d;
}
inline long long rev(const long long &k) {
  long long _, ans;
  exgcd(k, mo, ans, _);
  return (ans + mo) % mo;
}
struct edge {
  int v;
  edge *n;
} ep[maxn], *el[maxn];
int epl;
void addEdge(int u, int v) { el[u] = &(ep[epl++] = {v, el[u]}); }
void dfs(int u) {
  static int dfs_clock = 1;
  llab[u] = lab[u] = dfs_clock++;
  for (edge *e = el[u]; e; e = e->n) dfs(e->v);
  rlab[u] = dfs_clock;
}
struct node {
  int s, m;
  void mul(int v) {
    s = s * (long long)v % mo;
    m = m * (long long)v % mo;
  }
  void reset(int v) {
    s = v % mo;
    m = 1;
  }
} seg[lo * 2];
void segRM(int ql, int qr, int m, int p = 1, int l = 0, int r = lo) {
  if (ql <= l && r <= qr) {
    seg[p].mul(m);
    return;
  }
  if (seg[p].m > 1) {
    seg[((p) << 1)].mul(seg[p].m);
    seg[(((p) << 1) | 1)].mul(seg[p].m);
    seg[p].m = 1;
  }
  int mid = (l + r) >> 1;
  if (ql < mid) segRM(ql, qr, m, ((p) << 1), l, mid);
  if (mid < qr) segRM(ql, qr, m, (((p) << 1) | 1), mid, r);
  seg[p].reset(seg[((p) << 1)].s + seg[(((p) << 1) | 1)].s);
}
void segPS(int qk, int v, int p = 1, int l = 0, int r = lo) {
  if (r - l <= 1) {
    seg[p].reset(v);
    return;
  }
  if (seg[p].m > 1) {
    seg[((p) << 1)].mul(seg[p].m);
    seg[(((p) << 1) | 1)].mul(seg[p].m);
    seg[p].m = 1;
  }
  int mid = (l + r) >> 1;
  if (qk < mid)
    segPS(qk, v, ((p) << 1), l, mid);
  else
    segPS(qk, v, (((p) << 1) | 1), mid, r);
  seg[p].reset(seg[((p) << 1)].s + seg[(((p) << 1) | 1)].s);
}
int segPQ(int qk, int p = 1, int l = 0, int r = lo) {
  if (r - l <= 1) {
    return seg[p].s;
  }
  if (seg[p].m > 1) {
    seg[((p) << 1)].mul(seg[p].m);
    seg[(((p) << 1) | 1)].mul(seg[p].m);
    seg[p].m = 1;
  }
  int mid = (l + r) >> 1;
  if (qk < mid)
    return segPQ(qk, ((p) << 1), l, mid);
  else
    return segPQ(qk, (((p) << 1) | 1), mid, r);
}
int segRQ(int ql, int qr, int p = 1, int l = 0, int r = lo) {
  if (ql <= l && r <= qr) {
    return seg[p].s;
  }
  if (seg[p].m > 1) {
    seg[((p) << 1)].mul(seg[p].m);
    seg[(((p) << 1) | 1)].mul(seg[p].m);
    seg[p].m = 1;
  }
  int mid = (l + r) >> 1;
  int ans = 0;
  if (ql < mid) ans += segRQ(ql, qr, ((p) << 1), l, mid);
  if (mid < qr) ans += segRQ(ql, qr, (((p) << 1) | 1), mid, r);
  return ans % mo;
}
void segInit() {
  for (int i = 0; i < lo * 2; ++i) seg[i].m = 1;
}
int factor(int u) {
  int k = segPQ(lab[u]);
  return k * rev(val[u]) % mo;
}
void readint(int &k) {
  k = 0;
  char c = getchar();
  while (!isdigit(c)) c = getchar();
  while (isdigit(c)) {
    k = k * 10 + c - '0';
    c = getchar();
  }
}
struct que_t {
  int t, u, v;
  void read() {
    readint(t);
    if (t == 1) {
      readint(u);
      readint(v);
      par[++n] = u;
      val[n] = v;
      addEdge(par[n], n);
      v = n;
    } else {
      readint(u);
    }
  }
  void deal() {
    if (t == 1) {
      ++chi[u];
      segPS(lab[v], val[v] * (long long)factor(u) % mo);
      segRM(llab[u], rlab[u], (chi[u] + 1ll) * rev(chi[u]) % mo);
    } else {
      printf("%I64d\n",
             segRQ(llab[u], rlab[u]) * rev(factor(u)) % mo * (chi[u] + 1) % mo);
    }
  }
} ql[maxn];
int main() {
  segInit();
  readint(val[1]);
  readint(q);
  n = 1;
  for (int i = 0; i < q; ++i) ql[i].read();
  dfs(1);
  segPS(lab[1], val[1]);
  for (int i = 0; i < q; ++i) ql[i].deal();
  return 0;
}