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 + 1;
const int p = 1e9 + 7;
template <class T>
inline void read(T &x) {
  T f = 1;
  x = 0;
  char s = getchar();
  while (s < '0' || s > '9') {
    if (s == '-') f = -1;
    s = getchar();
  }
  while (s >= '0' && s <= '9') {
    x = (x * 10) + (s & 15);
    s = getchar();
  }
  x *= f;
}
struct Edge {
  long long u, v;
} e[maxn << 1];
long long head[maxn], ecnt;
inline void addedge(long long u, long long v) {
  e[++ecnt].v = v;
  e[ecnt].u = head[u];
  head[u] = ecnt;
}
inline long long ksm(long long a, long long b) {
  long long ans = 1;
  for (; b; b >>= 1, (a *= a) %= p)
    if (b & 1) (ans *= a) %= p;
  return ans;
}
long long val[maxn], inv[maxn];
long long q, opt[maxn], pa[maxn], ad[maxn], avl, u[maxn],
    IDX = 1, fa[maxn], top[maxn], idx, siz[maxn], dfn[maxn], s[maxn], cnt[maxn];
inline void dfs(long long x) {
  dfn[x] = (++idx);
  siz[x] = 1;
  for (long long i = head[x], v; i && (v = e[i].v); i = e[i].u) {
    dfs(v);
    siz[x] += siz[v];
  }
}
struct Segment_Tree {
  long long lazy[maxn << 2], val[maxn << 2], tag[maxn << 2];
  inline void init() {
    for (long long i = 1; i <= (idx << 2) - 1; i++)
      lazy[i] = 1, val[i] = 0, tag[i] = 1;
  }
  inline void pushup(long long rt) {
    val[rt] = (val[rt << 1] + val[rt << 1 | 1]) % p;
  }
  inline void pushdown(long long rt) {
    if (lazy[rt] == 1) return;
    (val[rt << 1] *= lazy[rt]) %= p;
    (val[rt << 1 | 1] *= lazy[rt]) %= p;
    (tag[rt << 1] *= lazy[rt]) %= p;
    (tag[rt << 1 | 1] *= lazy[rt]) %= p;
    (lazy[rt << 1] *= lazy[rt]) %= p;
    (lazy[rt << 1 | 1] *= lazy[rt]) %= p;
    lazy[rt] = 1;
  }
  inline void insert(long long rt, long long l, long long r, long long k,
                     long long ch) {
    if (l == r) return (void)(val[rt] = (ch * tag[rt]) % p);
    pushdown(rt);
    if (k <= ((l + r) >> 1))
      insert(rt << 1, l, ((l + r) >> 1), k, ch);
    else
      insert(rt << 1 | 1, ((l + r) >> 1) + 1, r, k, ch);
    pushup(rt);
  }
  inline void update(long long rt, long long l, long long r, long long L,
                     long long R, long long ch) {
    if (L <= l && r <= R)
      return (void)((lazy[rt] *= ch) %= p, (tag[rt] *= ch) %= p,
                    (val[rt] *= ch) %= p);
    pushdown(rt);
    if (L <= ((l + r) >> 1)) update(rt << 1, l, ((l + r) >> 1), L, R, ch);
    if (R > ((l + r) >> 1))
      update(rt << 1 | 1, ((l + r) >> 1) + 1, r, L, R, ch);
    pushup(rt);
  }
  inline long long query(long long rt, long long l, long long r, long long L,
                         long long R) {
    if (L <= l && r <= R) return val[rt];
    pushdown(rt);
    long long ans = 0;
    if (L <= ((l + r) >> 1)) ans += query(rt << 1, l, ((l + r) >> 1), L, R);
    if (R > ((l + r) >> 1))
      ans += query(rt << 1 | 1, ((l + r) >> 1) + 1, r, L, R);
    ans %= p;
    return ans;
  }
  inline long long get(long long rt, long long l, long long r, long long k) {
    if (!k) return 1;
    if (l == r) return tag[rt];
    pushdown(rt);
    if (k <= ((l + r) >> 1))
      return get(rt << 1, l, ((l + r) >> 1), k);
    else
      return get(rt << 1 | 1, ((l + r) >> 1) + 1, r, k);
  }
} t;
signed main() {
  read(val[1]);
  read(q);
  for (long long i = 1; i <= q; i++) {
    read(opt[i]);
    if (opt[i] & 1)
      read(pa[i]), read(avl), fa[++IDX] = pa[i], ad[i] = IDX, val[IDX] = avl,
                              addedge(pa[i], IDX);
    else
      read(u[i]);
  }
  dfs(1);
  for (long long i = 1; i <= idx; i++) cnt[i] = 1;
  t.init();
  t.insert(1, 1, idx, 1, val[1]);
  for (long long i = 1; i <= q; i++) {
    if (opt[i] & 1) {
      t.update(1, 1, idx, dfn[pa[i]], dfn[pa[i]] + siz[pa[i]] - 1,
               ksm(cnt[pa[i]], p - 2));
      cnt[pa[i]]++;
      t.update(1, 1, idx, dfn[pa[i]], dfn[pa[i]] + siz[pa[i]] - 1, cnt[pa[i]]);
      t.insert(1, 1, idx, dfn[ad[i]], val[ad[i]]);
    } else
      printf("%lld\n",
             t.query(1, 1, idx, dfn[u[i]], dfn[u[i]] + siz[u[i]] - 1) *
                 ksm(t.get(1, 1, idx, dfn[fa[u[i]]]), p - 2) % p);
  }
}