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;
bool debug = 0;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
string direc = "RDLU";
long long ln, lk, lm;
int qt[200105], qv[200105], qp[200105], qu[200105];
vector<int> mp[200105];
int st[200105], ed[200105], sz[200105], cnt, V[200105], Q, fa[200105],
    nid[200105];
void dfs(int x, int pa) {
  st[x] = ++cnt;
  for (int c : mp[x])
    if (c != pa) dfs(c, x);
  ed[x] = cnt;
}
long long fastPow(long long x, long long y) {
  long long ans = 1;
  while (y > 0) {
    if (y & 1) ans = (x * ans) % 1000000007;
    x = x * x % 1000000007;
    y >>= 1;
  }
  return ans;
}
long long inv(long long x) { return fastPow(x, 1000000007 - 2); }
const int MN = 200105 * 4;
int T[MN], lz[MN];
void addmod(int &x, int y) {
  if (y >= 1000000007) y -= 1000000007;
  x += y;
  if (x >= 1000000007) x -= 1000000007;
}
void mulmod(int &x, int y) { x = (long long)x * y % 1000000007; }
void down(int rt, int l, int r) {
  if (lz[rt] != 1) {
    mulmod(T[(rt << 1)], lz[rt]);
    mulmod(T[(rt << 1 | 1)], lz[rt]);
    mulmod(lz[(rt << 1)], lz[rt]);
    mulmod(lz[(rt << 1 | 1)], lz[rt]);
    lz[rt] = 1;
  }
}
void add(int rt, int l, int r, int x, int val) {
  if (r < x || x <= l) return;
  if (l + 1 == r) {
    addmod(T[rt], val);
    return;
  }
  int mid = (l + r) / 2;
  down(rt, l, r);
  add((rt << 1), l, mid, x, val);
  add((rt << 1 | 1), mid, r, x, val);
  T[rt] = 0;
  addmod(T[rt], T[(rt << 1)] + T[(rt << 1 | 1)]);
}
void multi(int rt, int l, int r, int L, int R, int val) {
  if (r <= L || R <= l) return;
  if (L <= l && r <= R) {
    mulmod(T[rt], val);
    mulmod(lz[rt], val);
    return;
  }
  down(rt, l, r);
  int mid = (l + r) / 2;
  multi((rt << 1), l, mid, L, R, val);
  multi((rt << 1 | 1), mid, r, L, R, val);
  T[rt] = 0;
  addmod(T[rt], T[(rt << 1)] + T[(rt << 1 | 1)]);
}
int qy(int rt, int l, int r, int L, int R) {
  if (r <= L || R <= l) return 0;
  if (L <= l && r <= R) return T[rt];
  down(rt, l, r);
  int mid = (l + r) / 2;
  int A = qy((rt << 1), l, mid, L, R);
  addmod(A, qy((rt << 1 | 1), mid, r, L, R));
  return A;
}
void fmain() {
  scanf("%d%d", V + 1, &Q);
  int id = 2;
  for (int(i) = 1; (i) <= (int)(Q); (i)++) {
    scanf("%d", qt + i);
    if (qt[i] == 1) {
      scanf("%d%d", qp + i, qv + i);
      V[id] = qv[i];
      nid[i] = id;
      fa[id] = qp[i];
      mp[fa[id]].push_back(id);
      id++;
    } else
      scanf("%d", qu + i);
  }
  dfs(1, 0);
  for (int(i) = 0; (i) < (int)(MN); (i)++) lz[i] = 1;
  sz[1] = 1;
  id--;
  add(1, 0, id, 1, V[1]);
  for (int(i) = 1; (i) <= (int)(Q); (i)++) {
    if (qt[i] == 1) {
      int v = nid[i], u = fa[v];
      long long mu =
          (long long)qy(1, 0, id, st[u] - 1, st[u]) * inv(V[u]) % 1000000007;
      add(1, 0, id, st[v], mu * V[v] % 1000000007);
      multi(1, 0, id, st[u] - 1, ed[u], inv(sz[u]) * (sz[u] + 1) % 1000000007);
      sz[v] = 1;
      sz[u]++;
    } else {
      int x = qu[i];
      int ans = qy(1, 0, id, st[x] - 1, ed[x]);
      if (x != 1) {
        int u = fa[x];
        mulmod(ans, inv(qy(1, 0, id, st[u] - 1, st[u])) * V[u] % 1000000007);
      }
      printf("%d\n", ans);
    }
  }
}
int main() {
  fmain();
  return 0;
}