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 TOUR = 1 << 18, MOD = 1e9 + 7;
int Add(int a, int b) {
  a += b;
  if (a >= MOD) a -= MOD;
  return a;
}
int Sub(int a, int b) {
  a -= b;
  if (a < 0) a += MOD;
  return a;
}
int Mul(int a, int b) { return (int)(((long long)a * b) % MOD); }
int Inverz(int x) {
  int ret = 1;
  for (int e = MOD - 2; e; e /= 2, x = Mul(x, x))
    if (e & 1) ret = Mul(ret, x);
  return ret;
}
int Div(int a, int b) { return Mul(a, Inverz(b)); }
struct node {
  int sum, mul, prop;
};
struct tour {
  node t[2 * TOUR];
  tour() {
    for (int i = 0; i < 2 * TOUR; i++) {
      t[i].sum = 0;
      t[i].mul = t[i].prop = 1;
    }
  }
  void propagiraj(int x) {
    for (int i = 2 * x; i <= 2 * x + 1; i++) {
      t[i].sum = Mul(t[i].sum, t[x].prop);
      t[i].mul = Mul(t[i].mul, t[x].prop);
      t[i].prop = Mul(t[i].prop, t[x].prop);
    }
    t[x].prop = 1;
  }
  void stavi_sum(int pos, int lo, int hi, int ind, int val) {
    if (lo >= ind + 1 || hi <= ind) return;
    if (lo == ind && hi == ind + 1) {
      t[pos].sum = Mul(t[pos].mul, val);
      return;
    }
    propagiraj(pos);
    stavi_sum(2 * pos + 0, lo, (lo + hi) / 2, ind, val);
    stavi_sum(2 * pos + 1, (lo + hi) / 2, hi, ind, val);
    t[pos].sum = Add(t[2 * pos].sum, t[2 * pos + 1].sum);
  }
  void stavi_sum(int pos, int val) { stavi_sum(1, 0, TOUR, pos, val); }
  void stavi_mul(int pos, int lo, int hi, int begin, int end, int val) {
    if (lo >= end || hi <= begin) return;
    if (lo >= begin && hi <= end) {
      t[pos].sum = Mul(t[pos].sum, val);
      t[pos].mul = Mul(t[pos].mul, val);
      t[pos].prop = Mul(t[pos].prop, val);
      return;
    }
    propagiraj(pos);
    stavi_mul(2 * pos + 0, lo, (lo + hi) / 2, begin, end, val);
    stavi_mul(2 * pos + 1, (lo + hi) / 2, hi, begin, end, val);
    t[pos].sum = Add(t[2 * pos].sum, t[2 * pos + 1].sum);
  }
  void stavi_mul(int begin, int end, int val) {
    stavi_mul(1, 0, TOUR, begin, end, val);
  }
  int query_sum(int pos, int lo, int hi, int begin, int end) {
    if (lo >= end || hi <= begin) return 0;
    if (lo >= begin && hi <= end) return t[pos].sum;
    propagiraj(pos);
    return Add(query_sum(2 * pos + 0, lo, (lo + hi) / 2, begin, end),
               query_sum(2 * pos + 1, (lo + hi) / 2, hi, begin, end));
  }
  int query_sum(int begin, int end) {
    return query_sum(1, 0, TOUR, begin, end);
  }
  int query_mul(int pos, int lo, int hi, int ind) {
    if (lo >= ind + 1 || hi <= ind) return 0;
    if (lo == ind && hi == ind + 1) return t[pos].mul;
    propagiraj(pos);
    return Add(query_mul(2 * pos + 0, lo, (lo + hi) / 2, ind),
               query_mul(2 * pos + 1, (lo + hi) / 2, hi, ind));
  }
  int query_mul(int ind) { return query_mul(1, 0, TOUR, ind); }
} T;
vector<int> V[TOUR];
pair<int, int> ev[TOUR];
int disc[TOUR], fin[TOUR], vr = 1;
int pocval[TOUR], par[TOUR];
int brdjec[TOUR];
void Dfs(int node) {
  disc[node] = vr++;
  for (int i = 0; i < (int)V[node].size(); i++) Dfs(V[node][i]);
  fin[node] = vr;
}
void Dodaj(int node) {
  int p = par[node];
  T.stavi_mul(disc[p], fin[p], Mul(Inverz(brdjec[p]), brdjec[p] + 1));
  T.stavi_sum(disc[node], pocval[node]);
  brdjec[p]++;
}
int Query(int node) {
  int ret = T.query_sum(disc[node], fin[node]);
  if (node) ret = Div(ret, T.query_mul(disc[par[node]]));
  return ret;
}
int main() {
  int brq, brcv = 1;
  scanf("%d%d", &pocval[0], &brq);
  for (int i = 0; i < brq; i++) {
    int st;
    scanf("%d", &st);
    if (st == 2) {
      int tmp;
      scanf("%d", &tmp);
      tmp--;
      ev[i] = pair<int, int>(st, tmp);
    } else {
      scanf("%d%d", &par[brcv], &pocval[brcv]);
      par[brcv]--;
      V[par[brcv]].push_back(brcv);
      ev[i] = pair<int, int>(st, brcv++);
    }
  }
  Dfs(0);
  T.stavi_sum(disc[0], pocval[0]);
  for (int i = 0; i < brcv; i++) brdjec[i] = 1;
  for (int i = 0; i < brq; i++) {
    if (ev[i].first == 1)
      Dodaj(ev[i].second);
    else
      printf("%d\n", Query(ev[i].second));
  }
  return 0;
}