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>
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
using namespace std;
int a, b, c, d, n, m, k;
int mas[200002], st[200002];
vector<int> gsm[200002];
const int MX = 5000;
int rev[MX + 1], val[MX + 1], sum[MX + 1], deg[MX + 1];
pair<int, int> pr[MX + 1];
pair<int, pair<int, int> > quer[200002];
int gpr[200002], cool[200002], gsum[200002], gdeg[200002];
void recalc(int v) {
  int cnt = 1, sum = mas[v];
  for (int _n(((int)((gsm[v]).size())) - 1), i(0); i <= _n; i++) {
    recalc(gsm[v][i]);
    ++cnt;
    sum += st[gsm[v][i]];
    if (sum >= 1000000007) sum -= 1000000007;
  }
  st[v] = (long long)sum * cnt % 1000000007;
  gsum[v] = sum;
  gdeg[v] = cnt;
}
void dfs(int v, int last, int p) {
  if (cool[v] != -1) {
    last = v;
    p = 1;
  } else {
    p = (long long)p * gdeg[v] % 1000000007;
  }
  for (int _n(((int)((gsm[v]).size())) - 1), i(0); i <= _n; i++) {
    int w = gsm[v][i];
    if (cool[w] != -1) {
      pr[cool[w]] = make_pair(cool[last], p);
    }
    dfs(w, last, p);
  }
}
void solve(pair<int, pair<int, int> > *quer, int m) {
  memset(cool, -1, sizeof(cool));
  int k = 0;
  cool[0] = k++;
  rev[0] = 0;
  for (int _n((m)-1), i(0); i <= _n; i++) {
    for (int _n((2) - 1), z(0); z <= _n; z++) {
      if (z == 1 && quer[i].first == 2) break;
      int w = z == 0 ? quer[i].second.first : quer[i].second.second;
      if (cool[w] != -1) continue;
      rev[k] = w;
      cool[w] = k++;
    }
  }
  if (k > MX) {
    throw std::runtime_error("WTF?!?!?");
  }
  for (int _n((k)-1), i(0); i <= _n; i++) {
    val[i] = st[rev[i]];
    sum[i] = gsum[rev[i]];
    deg[i] = gdeg[rev[i]];
    pr[i] = make_pair(-1, 0);
  }
  dfs(0, 0, 1);
  for (int _n((m)-1), i(0); i <= _n; i++) {
    if (quer[i].first == 1) {
      int par = cool[quer[i].second.first];
      int ch = cool[quer[i].second.second];
      int cv = mas[quer[i].second.second];
      pr[ch] = make_pair(par, 1);
      int delta = ((long long)deg[par] * cv + sum[par] + cv) % 1000000007;
      ++deg[par];
      sum[par] += cv;
      if (sum[par] >= 1000000007) sum[par] -= 1000000007;
      val[par] += delta;
      if (val[par] >= 1000000007) val[par] -= 1000000007;
      if (pr[par].first != -1) {
        sum[pr[par].first] =
            (sum[pr[par].first] + (long long)delta * pr[par].second) %
            1000000007;
      }
      val[ch] = cv;
      sum[ch] = cv;
      deg[ch] = 1;
      int v = par, p = delta;
      while (v != 0) {
        int ov = pr[v].first;
        p = (long long)p * pr[v].second % 1000000007;
        p = (long long)p * deg[ov] % 1000000007;
        val[ov] += p;
        if (val[ov] >= 1000000007) val[ov] -= 1000000007;
        if (pr[ov].first != -1) {
          sum[pr[ov].first] =
              (sum[pr[ov].first] + (long long)p * pr[ov].second) % 1000000007;
        }
        v = ov;
      }
    } else {
      printf("%d\n", val[cool[quer[i].second.first]]);
    }
  }
}
int main() {
  scanf("%d%d", &mas[0], &m);
  int k = 1;
  for (int _n((m)-1), i(0); i <= _n; i++) {
    scanf("%d", &a);
    if (a == 1) {
      scanf("%d%d", &a, &b);
      --a;
      quer[i] = make_pair(1, make_pair(a, k));
      gpr[k] = a;
      mas[k++] = b;
    } else {
      scanf("%d", &b);
      --b;
      quer[i] = make_pair(2, make_pair(b, -1));
    }
  }
  for (int _n((k)-1), i(0); i <= _n; i++) {
    gsm[i].clear();
  }
  int bl = sqrt((double)m) + 1;
  bl *= 4.5;
  for (int i = 0; i < m; i += bl) {
    recalc(0);
    solve(quer + i, min(bl, m - i));
    for (int j = i; j < i + bl && j < m; ++j) {
      if (quer[j].first == 1) {
        gsm[quer[j].second.first].push_back(quer[j].second.second);
      }
    }
  }
}