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 mod = 1e9 + 7;
template <typename T>
void read(T &x) {
  x = 0;
  char c;
  T t = 1;
  while (((c = getchar()) < '0' || c > '9') && c != '-')
    ;
  if (c == '-') {
    t = -1;
    c = getchar();
  }
  do (x *= 10) += (c - '0');
  while ((c = getchar()) >= '0' && c <= '9');
  x *= t;
}
template <typename T>
void write(T x) {
  int len = 0;
  char c[21];
  if (x < 0) putchar('-'), x *= (-1);
  do {
    ++len;
    c[len] = (x % 10) + '0';
  } while (x /= 10);
  for (int i = (len); i >= (1); --i) putchar(c[i]);
}
int n = 1, q, head[200010] = {}, edge_num = 0, pre[200010];
int sz[200010], id[200010], cnt = 0;
int du[200010];
struct edge {
  int to, next;
} e[200010];
struct query {
  int op, u, p;
  long long v;
} ask[200010];
struct line_tree {
  int l, r;
  long long lazy, sum;
} t[200010 * 3];
long long value1;
inline void addedge(const int &u, const int &v) {
  e[++edge_num] = edge{v, head[u]}, head[u] = edge_num;
}
void dfs(const int &v) {
  id[v] = ++cnt, sz[v] = 0;
  for (int i = head[v]; i; i = e[i].next) {
    int u = e[i].to;
    if (u == pre[v]) continue;
    dfs(u), sz[v] += (sz[u] + 1);
  }
}
void build(const int &o, const int &l, const int &r) {
  t[o].l = l, t[o].r = r, t[o].lazy = 1, t[o].sum = 0;
  if (l != r) {
    int mid = (l + r) >> 1;
    build(o << 1, l, mid), build(o << 1 | 1, mid + 1, r);
  }
}
inline void pushdown(const int &o) {
  if (t[o].lazy != 1) {
    (t[o << 1].lazy *= t[o].lazy) %= mod, (t[o << 1].sum *= t[o].lazy) %= mod;
    (t[o << 1 | 1].lazy *= t[o].lazy) %= mod,
        (t[o << 1 | 1].sum *= t[o].lazy) %= mod;
    t[o].lazy = 1;
  }
}
inline void pushup(const int &o) {
  t[o].sum = (t[o << 1].sum + t[o << 1 | 1].sum) % mod;
}
void update1(const int &o, const int &l, const int &r, const long long &value) {
  if (t[o].l == l && t[o].r == r) {
    (t[o].lazy *= value) %= mod, (t[o].sum *= value) %= mod;
    return;
  }
  pushdown(o);
  int mid = (t[o].l + t[o].r) >> 1;
  if (mid < l)
    update1(o << 1 | 1, l, r, value);
  else {
    if (r <= mid)
      update1(o << 1, l, r, value);
    else
      update1(o << 1, l, mid, value), update1(o << 1 | 1, mid + 1, r, value);
  }
  pushup(o);
}
void update2(const int &o, const int &pos, const long long &value) {
  if (t[o].l == t[o].r) {
    t[o].sum = value * t[o].lazy % mod;
    return;
  }
  pushdown(o);
  int mid = (t[o].l + t[o].r) >> 1;
  if (mid < pos)
    update2(o << 1 | 1, pos, value);
  else
    update2(o << 1, pos, value);
  pushup(o);
}
inline long long ksm(long long a, int b) {
  long long ans = 1;
  while (b) {
    if (b & 1) (ans *= a) %= mod, --b;
    (a *= a) %= mod, b >>= 1;
  }
  return ans;
}
long long getlazy(const int &o, const int &pos) {
  if (t[o].l == t[o].r) return t[o].lazy;
  pushdown(o);
  int mid = (t[o].l + t[o].r) >> 1;
  if (mid < pos)
    return getlazy(o << 1 | 1, pos);
  else
    return getlazy(o << 1, pos);
}
long long get(const int &o, const int &l, const int &r) {
  if (t[o].l == l && t[o].r == r) return t[o].sum;
  pushdown(o);
  int mid = (t[o].l + t[o].r) >> 1;
  if (mid < l)
    return get(o << 1 | 1, l, r);
  else {
    if (r <= mid)
      return get(o << 1, l, r);
    else
      return (get(o << 1, l, mid) + get(o << 1 | 1, mid + 1, r)) % mod;
  }
}
inline int AC() {
  read(value1), read(q), pre[1] = 0, du[1] = 1;
  for (int i = (1); i <= (q); ++i) {
    read(ask[i].op);
    if (ask[i].op == 1) {
      read(ask[i].p), read(ask[i].v), ++n, du[n] = 1;
      addedge(ask[i].p, n), pre[n] = ask[i].p;
    } else
      read(ask[i].u);
  }
  dfs(1), build(1, 1, n);
  n = 1, update2(1, 1, value1);
  for (int i = (1); i <= (q); ++i) {
    if (ask[i].op == 1) {
      int u = ask[i].p;
      ++n, ++du[u],
          update1(1, id[u], id[u] + sz[u],
                  du[u] * ksm(du[u] - 1, mod - 2) % mod);
      update2(1, id[n], ask[i].v);
    } else {
      long long ans;
      int u = ask[i].u;
      long long lazy = (u == 1 ? 1ll : ksm(getlazy(1, id[pre[u]]), mod - 2));
      write(get(1, id[u], id[u] + sz[u]) * lazy % mod), putchar('\n');
    }
  }
  return 0;
}
int main() {
  AC();
  return 0;
}