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;
int q;
vector<int> v[200002];
int n = 0;
long long int val[200002];
struct st {
  int ty;
  int a;
  int b;
  int to;
  st() {
    scanf("%d", &ty);
    if (ty == 1) {
      scanf("%d%d", &a, &b);
      a--;
      n++;
      to = n;
      v[a].push_back(n);
      val[to] = b;
    } else {
      scanf("%d", &a);
      a--;
    }
  }
};
vector<st> query;
struct ss {
  long long int sum;
  long long int lazy;
  ss() {
    lazy = 1;
    sum = 0;
  }
};
ss seg[200002 * 4];
int pp[200002];
int star[200002];
int en[200002];
int siz;
inline void dfs(int b) {
  star[b] = siz;
  siz++;
  for (int i = 0; i < v[b].size(); i++) {
    dfs(v[b][i]);
    pp[v[b][i]] = b;
  }
  en[b] = siz;
}
void update(int b) {
  if (seg[b].lazy != 1LL) {
    seg[b].sum *= seg[b].lazy;
    if (b * 2 + 2 < 200002 * 4) {
      seg[b * 2 + 1].lazy *= seg[b].lazy;
      if (seg[b * 2 + 1].lazy >= 1000000007LL) {
        seg[b * 2 + 1].lazy %= 1000000007LL;
      }
      seg[b * 2 + 2].lazy *= seg[b].lazy;
      if (seg[b * 2 + 2].lazy >= 1000000007LL) {
        seg[b * 2 + 2].lazy %= 1000000007LL;
      }
    }
    seg[b].lazy = 1;
    if (seg[b].sum >= 1000000007LL) {
      seg[b].sum %= 1000000007LL;
    }
  }
}
inline void mul(int b, int l, int r, int ll, int rr, long long int x) {
  update(b);
  if (ll <= l && r <= rr) {
    seg[b].lazy *= x;
    if (seg[b].lazy >= 1000000007LL) {
      seg[b].lazy %= 1000000007LL;
    }
    update(b);
    return;
  }
  if (r <= ll || rr <= l) {
    return;
  }
  mul(b * 2 + 1, l, (l + r) >> 1, ll, rr, x);
  mul(b * 2 + 2, (l + r) >> 1, r, ll, rr, x);
  seg[b].sum = seg[b * 2 + 1].sum + seg[b * 2 + 2].sum;
  if (seg[b].sum >= 1000000007LL) {
    seg[b].sum %= 1000000007LL;
  }
}
long long int ppow(long long int i, long long int j) {
  long long int res = 1LL;
  while (j) {
    if ((j & 1LL)) {
      res *= i;
      if (res >= 1000000007LL) {
        res %= 1000000007LL;
      }
    }
    i *= i;
    if (i >= 1000000007LL) {
      i %= 1000000007LL;
    }
    j >>= 1LL;
  }
  return res;
}
inline void add(int b, int l, int r, int ll, long long int x) {
  update(b);
  if (l <= ll && ll < r) {
    if (l + 1 == r) {
      seg[b].sum += x;
      if (seg[b].sum >= 1000000007LL) {
        seg[b].sum %= 1000000007LL;
      }
      return;
    }
    add(b * 2 + 1, l, (l + r) >> 1, ll, x);
    add(b * 2 + 2, (l + r) >> 1, r, ll, x);
    seg[b].sum = seg[b * 2 + 1].sum + seg[b * 2 + 2].sum;
    if (seg[b].sum >= 1000000007LL) {
      seg[b].sum %= 1000000007LL;
    }
  }
}
int deg[200002];
long long int bit[200002];
void add(int b, long long int x) {
  b++;
  while (b < 200002) {
    bit[b] *= x;
    if (bit[b] >= 1000000007LL) {
      bit[b] %= 1000000007LL;
    }
    b += b & -b;
  }
}
long long int sum(int b) {
  long long int res = 1;
  b++;
  while (b) {
    res *= bit[b];
    if (res >= 1000000007LL) {
      res %= 1000000007LL;
    }
    b -= b & -b;
  }
  return res;
}
long long int inv[200002];
void add_range(int a, int b, long long int x) {
  add(a, x);
  add(b, ppow(x, 1000000007LL - 2));
}
void add_degree(int b, int x) {
  mul(0, 0, n, star[b], en[b],
      (inv[deg[b]] * (long long int)(deg[b] + x)) % 1000000007LL);
  add_range(star[b], en[b],
            (inv[deg[b]] * (long long int)(deg[b] + x)) % 1000000007LL);
  deg[b] += x;
}
inline long long int sumup(int b, int l, int r, int ll, int rr) {
  update(b);
  if (ll <= l && r <= rr) {
    return seg[b].sum;
  }
  if (r <= ll || rr <= l) {
    return 0LL;
  }
  long long int k = sumup(b * 2 + 1, l, (l + r) >> 1, ll, rr) +
                    sumup(b * 2 + 2, (l + r) >> 1, r, ll, rr);
  if (k >= 1000000007LL) {
    k %= 1000000007LL;
  }
  return k;
}
int main() {
  scanf("%I64d%d", &val[0], &q);
  for (int i = 0; i < q; i++) {
    query.push_back(st());
  }
  n++;
  for (int i = 0; i < n; i++) {
    deg[i] = 1;
  }
  for (int i = 0; i < 200002; i++) {
    bit[i] = 1;
    inv[i] = ppow(i, 1000000007LL - 2);
  }
  dfs(0);
  pp[0] = -1;
  add(0, 0, n, 0, val[0]);
  for (int i = 0; i < q; i++) {
    if (query[i].ty == 1) {
      add_degree(query[i].a, 1);
      long long int get_val = sum(star[query[i].to]);
      get_val *= (long long int)(query[i].b);
      if (get_val >= 1000000007LL) {
        get_val %= 1000000007LL;
      }
      add(0, 0, n, star[query[i].to], get_val);
    } else {
      long long int sum2 = sumup(0, 0, n, star[query[i].a], en[query[i].a]);
      if (query[i].a) {
        int pre_ed = pp[query[i].a];
        sum2 *= ppow(sum(star[pre_ed]), 1000000007LL - 2);
        if (sum2 >= 1000000007LL) {
          sum2 %= 1000000007LL;
        }
      }
      printf("%lld\n", sum2);
    }
  }
  return 0;
}