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 N = 2e5 + 10;
int n, num;
vector<int> p[N];
int per[N], in[N], out[N], nod[N], ty[N];
bool ok[N];
long long sz[N], v[N];
void init(int x) {
  in[x] = ++num;
  for (int i = 0; i < p[x].size(); i++) {
    init(p[x][i]);
  }
  out[x] = num;
}
long long mod = 1e9 + 7;
long long dp[N * 4];
long long rsz[N * 4];
long long laz[N * 4];
long long addm(long long x, long long y) { return (x + y) % mod; }
long long mul(long long x, long long y) { return (x * y) % mod; }
void up(int p) {
  if (laz[p] == 1) return;
  dp[2 * p] = mul(dp[2 * p], laz[p]);
  dp[2 * p + 1] = mul(dp[2 * p + 1], laz[p]);
  laz[2 * p] = mul(laz[2 * p], laz[p]);
  laz[2 * p + 1] = mul(laz[2 * p + 1], laz[p]);
  rsz[2 * p] = mul(rsz[2 * p], laz[p]);
  rsz[2 * p + 1] = mul(rsz[2 * p + 1], laz[p]);
  laz[p] = 1;
}
void add(int in, long long x, int l = 1, int h = n, int p = 1) {
  if (l == h) {
    dp[p] = mul(x, rsz[p]);
    return;
  }
  up(p);
  int m = (l + h) / 2;
  if (in <= m) {
    add(in, x, l, m, 2 * p);
  } else
    add(in, x, m + 1, h, 2 * p + 1);
  dp[p] = addm(dp[2 * p], dp[2 * p + 1]);
}
void mulSz(int a, int b, long long x, int l = 1, int h = n, int p = 1) {
  if (l == a && b == h) {
    dp[p] = mul(x, dp[p]);
    laz[p] = mul(x, laz[p]);
    rsz[p] = mul(x, rsz[p]);
    return;
  }
  up(p);
  int m = (l + h) / 2;
  if (b <= m) {
    mulSz(a, b, x, l, m, 2 * p);
  } else if (a > m)
    mulSz(a, b, x, m + 1, h, 2 * p + 1);
  else {
    mulSz(a, m, x, l, m, 2 * p);
    mulSz(m + 1, b, x, m + 1, h, 2 * p + 1);
  }
  dp[p] = addm(dp[2 * p], dp[2 * p + 1]);
}
long long calSz(int in, int l = 1, int h = n, int p = 1) {
  if (l == h) {
    return rsz[p];
  }
  up(p);
  int m = (l + h) / 2;
  if (in <= m)
    return calSz(in, l, m, 2 * p);
  else
    return calSz(in, m + 1, h, 2 * p + 1);
}
long long cal(int a, int b, int l = 1, int h = n, int p = 1) {
  if (a == l && b == h) {
    return dp[p];
  }
  up(p);
  int m = (l + h) / 2;
  if (b <= m) {
    return cal(a, b, l, m, 2 * p);
  } else if (a > m) {
    return cal(a, b, m + 1, h, 2 * p + 1);
  } else {
    return addm(cal(a, m, l, m, 2 * p), cal(m + 1, b, m + 1, h, 2 * p + 1));
  }
}
long long pw(long long x, long long p) {
  if (!p) return 1;
  long long z = pw(x, p / 2);
  z = mul(z, z);
  if (p % 2 == 0) return z;
  z = mul(z, x);
  return z;
}
int pp[N];
int main() {
  int q;
  long long v1;
  cin >> v1 >> q;
  n = 1;
  for (int i = 0; i < q; i++) {
    scanf("%d", &ty[i]);
    if (ty[i] == 1) {
      scanf("%d%lld", &per[i], &v[i]);
      n++;
      nod[i] = n;
      p[per[i]].push_back(n);
      pp[n] = per[i];
    } else {
      scanf("%d", &nod[i]);
    }
  }
  for (int i = 0; i < N * 4; i++) {
    rsz[i] = 1;
    laz[i] = 1;
  }
  init(1);
  add(in[1], v1);
  sz[1]++;
  int x;
  for (int i = 0; i < q; i++) {
    if (ty[i] == 1) {
      sz[nod[i]]++;
      long long nw = pw(sz[per[i]], mod - 2);
      sz[per[i]]++;
      nw = mul(nw, sz[per[i]]);
      mulSz(in[per[i]], out[per[i]], nw);
      add(in[nod[i]], v[i]);
    } else {
      long long res = cal(in[nod[i]], out[nod[i]]);
      if (pp[nod[i]]) res = mul(res, pw(calSz(in[pp[nod[i]]]), mod - 2));
      printf("%lld\n", res);
    }
  }
  return 0;
}