/tmp/solutions/build/vertex_set_path_composite-logn.cpp:
    1|       |#include <common.h>
    2|       |#include <toy/bit.h>
    3|       |prelude;
    4|       |
    5|       |namespace {
    6|       |
    7|       |constexpr int N = 200001;
    8|       |constexpr int P = 998244353;
    9|       |
   10|       |struct Vertex {
   11|       |  u32 a, b;
   12|       |};
   13|       |struct Segment {
   14|       |  u32 a, b, c;
   15|       |  Segment() = default;
   16|     12|  Segment(Vertex v) : a{v.a}, b{v.b}, c{v.b} {}
   17|     33|  Segment(u32 a, u32 b, u32 c) : a{a}, b{b}, c{c} {}
   18|       |};
   19|       |struct Node {
   20|       |  Vertex v;
   21|       |  Segment s, t;
   22|       |  int l, r, p;
   23|       |} node[N];
   24|     25|auto operator+(const Segment &l, const Segment &r) -> Segment {
   25|     25|  u32 x = u64(l.a) * r.a % P;
   26|     25|  u32 y = (u64(l.a) * r.b + l.b) % P;
   27|     25|  u32 z = (u64(r.a) * l.c + r.c) % P;
   28|     25|  return {x, y, z};
   29|     25|}
   30|      2|auto operator+(const Segment &l, u32 r) -> u32 {
   31|      2|  return (u64(l.a) * r + l.b) % P;
   32|      2|}
   33|      4|auto operator+(u32 l, const Segment &r) -> u32 {
   34|      4|  return (u64(r.a) * l + r.c) % P;
   35|      4|}
   36|       |u32 a[N];
   37|       |u32 b[N];
   38|       |int head[N];
   39|       |int size[N];
   40|       |int depth[N];
   41|       |int heavy[N];
   42|       |int ances[N];
   43|       |int parent[N];
   44|       |int node2id[N];
   45|       |u8 priority[N];
   46|       |int id;
   47|       |struct {
   48|       |  int to;
   49|       |  int next;
   50|       |} edge[N * 2];
   51|       |
   52|      5|def build_step_1(int u, int p) -> void {
   53|      5|  size[u] = 1;
   54|     13|  for (int e = head[u]; e; e = edge[e].next) {
                                         ^8
  ------------------
  |  Branch (54:25): [True: 61.54%, False: 38.46%]
  ------------------
   55|      8|    int v = edge[e].to;
   56|      8|    if (v != p) {
  ------------------
  |  Branch (56:9): [True: 50.00%, False: 50.00%]
  ------------------
   57|      4|      build_step_1(v, u);
   58|      4|      size[u] += size[v];
   59|      4|      if (heavy[u] == 0 || size[v] > size[heavy[u]]) {
                                         ^1
  ------------------
  |  Branch (59:11): [True: 75.00%, False: 25.00%]
  |  Branch (59:28): [True: 0.00%, False: 100.00%]
  ------------------
   60|      3|        heavy[u] = v;
   61|      3|      }
   62|      4|    }
   63|      8|  }
   64|      5|}
   65|       |
   66|      5|def build_step_2(int u, int w, int p, int d) -> void {
   67|      5|  int i = ++id;
   68|      5|  node2id[u] = i;
   69|      5|  depth[i] = d;
   70|      5|  ances[i] = node2id[w];
   71|      5|  parent[i] = node2id[p];
   72|      5|  node[i].v = {a[u], b[u]};
   73|     13|  for (int e = head[u]; e; e = edge[e].next) {
                                         ^8
  ------------------
  |  Branch (73:25): [True: 61.54%, False: 38.46%]
  ------------------
   74|      8|    int v = edge[e].to;
   75|      8|    if (v != p && v != heavy[u]) {
                                ^4
  ------------------
  |  Branch (75:9): [True: 50.00%, False: 50.00%]
  |  Branch (75:19): [True: 25.00%, False: 75.00%]
  ------------------
   76|      1|      build_step_2(v, v, u, d + 1);
   77|      1|    }
   78|      8|  }
   79|      5|  priority[i] = u8(log(i ^ (id + 1)));
   80|      5|  if (u != w) {
  ------------------
  |  Branch (80:7): [True: 60.00%, False: 40.00%]
  ------------------
   81|      3|    int p = parent[i];
   82|      3|    int l = 0;
   83|      5|    while (p && priority[p] < priority[i]) {
                              ^4
  ------------------
  |  Branch (83:12): [True: 80.00%, False: 20.00%]
  |  Branch (83:17): [True: 50.00%, False: 50.00%]
  ------------------
   84|      2|      l = p;
   85|      2|      p = node[p].p;
   86|      2|    }
   87|      3|    node[p].r = i;
   88|      3|    node[i].p = p;
   89|      3|    node[i].l = l;
   90|      3|    node[l].p = i;
   91|      3|  }
   92|      5|  if (int v = heavy[u]; v) {
  ------------------
  |  Branch (92:25): [True: 60.00%, False: 40.00%]
  ------------------
   93|      3|    build_step_2(v, w, u, d + 1);
   94|      3|  }
   95|      5|}
   96|       |
   97|      6|def maintain(int u) -> void {
   98|      6|  node[u].s = (node[u].t = node[node[u].l].s + node[u].v) + node[node[u].r].s;
   99|      6|}
  100|       |
  101|      1|template <typename T> T apply(int k, T x) {
  102|      2|  for (int u = k; u; u = node[u].p) {
                                   ^1
  ------------------
  |  Branch (102:19): [True: 0.00%, False: 0.00%]
  ------------------
  |  Branch (102:19): [True: 50.00%, False: 50.00%]
  ------------------
  103|      1|    if (u <= k) {
  ------------------
  |  Branch (103:9): [True: 0.00%, False: 0.00%]
  ------------------
  |  Branch (103:9): [True: 100.00%, False: 0.00%]
  ------------------
  104|      1|      x = node[u].t + x;
  105|      1|    }
  106|      1|  }
  107|      1|  return x;
  108|      1|}
  ------------------
  | Unexecuted instantiation: vertex_set_path_composite-logn.cpp:_ZN12_GLOBAL__N_15applyIjEET_iS1_
  ------------------
  | vertex_set_path_composite-logn.cpp:_ZN12_GLOBAL__N_15applyINS_7SegmentEEET_iS2_:
  |  101|      1|template <typename T> T apply(int k, T x) {
  |  102|      2|  for (int u = k; u; u = node[u].p) {
  |                                   ^1
  |  ------------------
  |  |  Branch (102:19): [True: 50.00%, False: 50.00%]
  |  ------------------
  |  103|      1|    if (u <= k) {
  |  ------------------
  |  |  Branch (103:9): [True: 100.00%, False: 0.00%]
  |  ------------------
  |  104|      1|      x = node[u].t + x;
  |  105|      1|    }
  |  106|      1|  }
  |  107|      1|  return x;
  |  108|      1|}
  ------------------
  109|       |
  110|      4|template <typename T> T apply(int l, int r, T x) {
  111|      4|  Segment t = {1, 0, 0};
  112|      4|  int u = l;
  113|      4|  int v = r;
  114|      8|  while (u != v) {
  ------------------
  |  Branch (114:10): [True: 0.00%, False: 100.00%]
  ------------------
  |  Branch (114:10): [True: 57.14%, False: 42.86%]
  ------------------
  115|      4|    if (priority[u] < priority[v]) {
  ------------------
  |  Branch (115:9): [True: 0.00%, False: 0.00%]
  ------------------
  |  Branch (115:9): [True: 50.00%, False: 50.00%]
  ------------------
  116|      2|      if (l <= u) {
  ------------------
  |  Branch (116:11): [True: 0.00%, False: 0.00%]
  ------------------
  |  Branch (116:11): [True: 100.00%, False: 0.00%]
  ------------------
  117|      2|        t = (t + node[u].v) + node[node[u].r].s;
  118|      2|      }
  119|      2|      u = node[u].p;
  120|      2|    } else {
  121|      2|      if (v <= r) {
  ------------------
  |  Branch (121:11): [True: 0.00%, False: 0.00%]
  ------------------
  |  Branch (121:11): [True: 100.00%, False: 0.00%]
  ------------------
  122|      2|        x = node[v].t + x;
  123|      2|      }
  124|      2|      v = node[v].p;
  125|      2|    }
  126|      4|  }
  127|      4|  x = t + (node[u].v + x);
  128|      4|  return x;
  129|      4|}
  ------------------
  | vertex_set_path_composite-logn.cpp:_ZN12_GLOBAL__N_15applyIjEET_iiS1_:
  |  110|      1|template <typename T> T apply(int l, int r, T x) {
  |  111|      1|  Segment t = {1, 0, 0};
  |  112|      1|  int u = l;
  |  113|      1|  int v = r;
  |  114|      1|  while (u != v) {
  |  ------------------
  |  |  Branch (114:10): [True: 0.00%, False: 100.00%]
  |  ------------------
  |  115|      0|    if (priority[u] < priority[v]) {
  |  ------------------
  |  |  Branch (115:9): [True: 0.00%, False: 0.00%]
  |  ------------------
  |  116|      0|      if (l <= u) {
  |  ------------------
  |  |  Branch (116:11): [True: 0.00%, False: 0.00%]
  |  ------------------
  |  117|      0|        t = (t + node[u].v) + node[node[u].r].s;
  |  118|      0|      }
  |  119|      0|      u = node[u].p;
  |  120|      0|    } else {
  |  121|      0|      if (v <= r) {
  |  ------------------
  |  |  Branch (121:11): [True: 0.00%, False: 0.00%]
  |  ------------------
  |  122|      0|        x = node[v].t + x;
  |  123|      0|      }
  |  124|      0|      v = node[v].p;
  |  125|      0|    }
  |  126|      0|  }
  |  127|      1|  x = t + (node[u].v + x);
  |  128|      1|  return x;
  |  129|      1|}
  ------------------
  | vertex_set_path_composite-logn.cpp:_ZN12_GLOBAL__N_15applyINS_7SegmentEEET_iiS2_:
  |  110|      3|template <typename T> T apply(int l, int r, T x) {
  |  111|      3|  Segment t = {1, 0, 0};
  |  112|      3|  int u = l;
  |  113|      3|  int v = r;
  |  114|      7|  while (u != v) {
  |  ------------------
  |  |  Branch (114:10): [True: 57.14%, False: 42.86%]
  |  ------------------
  |  115|      4|    if (priority[u] < priority[v]) {
  |  ------------------
  |  |  Branch (115:9): [True: 50.00%, False: 50.00%]
  |  ------------------
  |  116|      2|      if (l <= u) {
  |  ------------------
  |  |  Branch (116:11): [True: 100.00%, False: 0.00%]
  |  ------------------
  |  117|      2|        t = (t + node[u].v) + node[node[u].r].s;
  |  118|      2|      }
  |  119|      2|      u = node[u].p;
  |  120|      2|    } else {
  |  121|      2|      if (v <= r) {
  |  ------------------
  |  |  Branch (121:11): [True: 100.00%, False: 0.00%]
  |  ------------------
  |  122|      2|        x = node[v].t + x;
  |  123|      2|      }
  |  124|      2|      v = node[v].p;
  |  125|      2|    }
  |  126|      4|  }
  |  127|      3|  x = t + (node[u].v + x);
  |  128|      3|  return x;
  |  129|      3|}
  ------------------
  130|       |
  131|       |} // namespace
  132|       |
  133|      1|int main() {
  134|      1|  rd rd;
  135|      1|  wt wt;
  136|      1|  int n = rd.uh();
  137|      1|  int q = rd.uh();
  138|      1|#ifdef LOCAL
  139|      1|  id = 0;
  140|      1|  std::memset(head, 0, 4 * n);
  141|      1|  std::memset(heavy, 0, 4 * n);
  142|      1|  std::memset(node, 0, (n + 1) * sizeof(Node));
  143|      1|#endif
  144|      1|  node[0].s.a = 1;
  145|      6|  for (int i = 0; i < n; ++i) a[i] = rd.uw(), b[i] = rd.uw();
                                       ^5   ^5
  ------------------
  |  Branch (145:19): [True: 83.33%, False: 16.67%]
  ------------------
  146|      5|  for (int i = 1; i < n; ++i) {
                                       ^4
  ------------------
  |  Branch (146:19): [True: 80.00%, False: 20.00%]
  ------------------
  147|      4|    int u = rd.uh();
  148|      4|    int v = rd.uh();
  149|      4|    edge[i * 2 | 0] = {v, head[u]}, head[u] = i * 2 | 0;
  150|      4|    edge[i * 2 | 1] = {u, head[v]}, head[v] = i * 2 | 1;
  151|      4|  }
  152|      1|  build_step_1(0, 0);
  153|      1|  build_step_2(0, 0, 0, 0);
  154|      6|  for (int i = 1; i <= n; ++i) {
                                        ^5
  ------------------
  |  Branch (154:19): [True: 83.33%, False: 16.67%]
  ------------------
  155|      5|    if (node[i].r == 0) {
  ------------------
  |  Branch (155:9): [True: 60.00%, False: 40.00%]
  ------------------
  156|      8|      for (int u = i; u && u <= i; u = node[u].p) {
                                         ^6      ^5
  ------------------
  |  Branch (156:23): [True: 75.00%, False: 25.00%]
  |  Branch (156:28): [True: 83.33%, False: 16.67%]
  ------------------
  157|      5|        maintain(u);
  158|      5|      }
  159|      3|    }
  160|      5|  }
  161|      6|  while (q--) {
  ------------------
  |  Branch (161:10): [True: 83.33%, False: 16.67%]
  ------------------
  162|      5|    let t = rd.u1();
  163|      5|    if (t == 0) {
  ------------------
  |  Branch (163:9): [True: 20.00%, False: 80.00%]
  ------------------
  164|      1|      int u = node2id[rd.uh()];
  165|      1|      node[u].v = {rd.uw(), rd.uw()};
  166|      2|      for (; u; u = node[u].p) {
                              ^1
  ------------------
  |  Branch (166:14): [True: 50.00%, False: 50.00%]
  ------------------
  167|      1|        maintain(u);
  168|      1|      }
  169|      1|    }
  170|      5|    if (t == 1) {
  ------------------
  |  Branch (170:9): [True: 80.00%, False: 20.00%]
  ------------------
  171|      4|      int u = node2id[rd.uh()];
  172|      4|      int v = node2id[rd.uh()];
  173|      4|      u32 x = rd.uw();
  174|      4|      Segment f = {1, 0, 0};
  175|      5|      while (ances[u] != ances[v]) {
  ------------------
  |  Branch (175:14): [True: 20.00%, False: 80.00%]
  ------------------
  176|      1|        if (depth[ances[u]] >= depth[ances[v]]) {
  ------------------
  |  Branch (176:13): [True: 0.00%, False: 100.00%]
  ------------------
  177|      0|          x = apply(u, x);
  178|      0|          u = parent[ances[u]];
  179|      1|        } else {
  180|      1|          f = apply(v, f);
  181|      1|          v = parent[ances[v]];
  182|      1|        }
  183|      1|      }
  184|      4|      if (u >= v) {
  ------------------
  |  Branch (184:11): [True: 25.00%, False: 75.00%]
  ------------------
  185|      1|        x = apply(v, u, x);
  186|      3|      } else {
  187|      3|        f = apply(u, v, f);
  188|      3|      }
  189|      4|      x = x + f;
  190|      4|      wt.uw(x);
  191|      4|    }
  192|      5|  }
  193|      1|  return 0;
  194|      1|}