#include <type_traits>
#include <cstdint>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <numeric>
#include <cassert>
#include <climits>
#include <map>
#include <array>
#include <bitset>

using namespace std;

// tourist's modular-arithmetic class
template<typename T>
T inverse(T a, T m) {
    T u = 0, v = 1;
    while (a != 0) {
        T t = m / a;
        m -= t * a;
        swap(a, m);
        u -= t * v;
        swap(u, v);
    }
    assert(m == 1);
    return u;
}

template<typename T>
class Modular {
public:
    using Type = typename decay<decltype(T::value)>::type;

    constexpr Modular() : value() {}

    template<typename U>
    Modular(const U &x) {
        value = normalize(x);
    }

    template<typename U>
    static Type normalize(const U &x) {
        Type v;
        if (-mod() <= x && x < mod()) v = static_cast<Type>(x);
        else v = static_cast<Type>(x % mod());
        if (v < 0) v += mod();
        return v;
    }

    const Type &operator()() const { return value; }

    template<typename U>
    explicit operator U() const { return static_cast<U>(value); }

    constexpr static Type mod() { return T::value; }

    Modular &operator+=(const Modular &other) {
        if ((value += other.value) >= mod()) value -= mod();
        return *this;
    }

    Modular &operator-=(const Modular &other) {
        if ((value -= other.value) < 0) value += mod();
        return *this;
    }

    template<typename U>
    Modular &operator+=(const U &other) { return *this += Modular(other); }

    template<typename U>
    Modular &operator-=(const U &other) { return *this -= Modular(other); }

    Modular &operator++() { return *this += 1; }

    Modular &operator--() { return *this -= 1; }

    Modular operator++(int) {
        Modular result(*this);
        *this += 1;
        return result;
    }

    Modular operator--(int) {
        Modular result(*this);
        *this -= 1;
        return result;
    }

    Modular operator-() const { return Modular(-value); }

    template<typename U = T>
    typename enable_if<is_same<typename Modular<U>::Type, int>::value, Modular>::type &operator*=(const Modular &rhs) {
#ifdef _WIN32
        uint64_t x = static_cast<int64_t>(value) * static_cast<int64_t>(rhs.value);
        uint32_t xh = static_cast<uint32_t>(x >> 32), xl = static_cast<uint32_t>(x), d, m;
        asm(
        "divl %4; \n\t"
        : "=a" (d), "=d" (m)
        : "d" (xh), "a" (xl), "r" (mod())
        );
        value = m;
#else
        value = normalize(static_cast<int64_t>(value) * static_cast<int64_t>(rhs.value));
#endif
        return *this;
    }

    template<typename U = T>
    typename enable_if<is_same<typename Modular<U>::Type, int64_t>::value, Modular>::type &
    operator*=(const Modular &rhs) {
        int64_t q = static_cast<int64_t>(static_cast<long double>(value) * rhs.value / mod());
        value = normalize(value * rhs.value - q * mod());
        return *this;
    }

    template<typename U = T>
    typename enable_if<!is_integral<typename Modular<U>::Type>::value, Modular>::type &operator*=(const Modular &rhs) {
        value = normalize(value * rhs.value);
        return *this;
    }

    Modular &operator/=(const Modular &other) { return *this *= Modular(inverse(other.value, mod())); }

    template<typename U>
    friend const Modular<U> &abs(const Modular<U> &v) { return v; }

    template<typename U>
    friend bool operator==(const Modular<U> &lhs, const Modular<U> &rhs);

    template<typename U>
    friend bool operator<(const Modular<U> &lhs, const Modular<U> &rhs);

    template<typename U>
    friend std::istream &operator>>(std::istream &stream, Modular<U> &number);

private:
    Type value;
};

template<typename T>
bool operator==(const Modular<T> &lhs, const Modular<T> &rhs) { return lhs.value == rhs.value; }

template<typename T, typename U>
bool operator==(const Modular<T> &lhs, U rhs) { return lhs == Modular<T>(rhs); }

template<typename T, typename U>
bool operator==(U lhs, const Modular<T> &rhs) { return Modular<T>(lhs) == rhs; }

template<typename T>
bool operator!=(const Modular<T> &lhs, const Modular<T> &rhs) { return !(lhs == rhs); }

template<typename T, typename U>
bool operator!=(const Modular<T> &lhs, U rhs) { return !(lhs == rhs); }

template<typename T, typename U>
bool operator!=(U lhs, const Modular<T> &rhs) { return !(lhs == rhs); }

template<typename T>
bool operator<(const Modular<T> &lhs, const Modular<T> &rhs) { return lhs.value < rhs.value; }

template<typename T>
Modular<T> operator+(const Modular<T> &lhs, const Modular<T> &rhs) { return Modular<T>(lhs) += rhs; }

template<typename T, typename U>
Modular<T> operator+(const Modular<T> &lhs, U rhs) { return Modular<T>(lhs) += rhs; }

template<typename T, typename U>
Modular<T> operator+(U lhs, const Modular<T> &rhs) { return Modular<T>(lhs) += rhs; }

template<typename T>
Modular<T> operator-(const Modular<T> &lhs, const Modular<T> &rhs) { return Modular<T>(lhs) -= rhs; }

template<typename T, typename U>
Modular<T> operator-(const Modular<T> &lhs, U rhs) { return Modular<T>(lhs) -= rhs; }

template<typename T, typename U>
Modular<T> operator-(U lhs, const Modular<T> &rhs) { return Modular<T>(lhs) -= rhs; }

template<typename T>
Modular<T> operator*(const Modular<T> &lhs, const Modular<T> &rhs) { return Modular<T>(lhs) *= rhs; }

template<typename T, typename U>
Modular<T> operator*(const Modular<T> &lhs, U rhs) { return Modular<T>(lhs) *= rhs; }

template<typename T, typename U>
typename enable_if<is_integral<U>::value, Modular<T>>::type operator*(U lhs, const Modular<T> &rhs) {
    return Modular<T>(lhs) *= rhs;
}

template<typename T>
Modular<T> operator/(const Modular<T> &lhs, const Modular<T> &rhs) { return Modular<T>(lhs) /= rhs; }

template<typename T, typename U>
Modular<T> operator/(const Modular<T> &lhs, U rhs) { return Modular<T>(lhs) /= rhs; }

template<typename T, typename U>
Modular<T> operator/(U lhs, const Modular<T> &rhs) { return Modular<T>(lhs) /= rhs; }

template<typename T, typename U>
Modular<T> power(const Modular<T> &a, const U &b) {
    assert(b >= 0);
    Modular<T> x = a, res = 1;
    U p = b;
    while (p > 0) {
        if (p & 1) res *= x;
        x *= x;
        p >>= 1;
    }
    return res;
}

template<typename T>
bool IsZero(const Modular<T> &number) {
    return number() == 0;
}

template<typename T>
string to_string(const Modular<T> &number) {
    return to_string(number());
}

template<typename T>
std::ostream &operator<<(std::ostream &stream, const Modular<T> &number) {
    return stream << number();
}

template<typename T>
std::istream &operator>>(std::istream &stream, Modular<T> &number) {
    typename common_type<typename Modular<T>::Type, int64_t>::type x;
    stream >> x;
    number.value = Modular<T>::normalize(x);
    return stream;
}

struct fast_ios {
    fast_ios() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
    };
} fast_ios_;

template<typename A, typename B>
bool chkmin(A &a, const B &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

template<typename A, typename B>
bool chkmax(A &a, const B &b) {
    if (b > a) {
        a = b;
        return true;
    }
    return false;
}

int cas;

ostream &kase() {
    return cout << "Case #" << ++cas << ": ";
}

template<typename T>
ostream &operator<<(ostream &stream, const vector<T> &vec) {
    if (!vec.empty()) {
        stream << vec[0];
        for (size_t i = 1; i != vec.size(); ++i)
            stream << ' ' << vec[i];
    }
    return stream;
}

template<typename T>
void print(const vector<T> &t) { cout << t << '\n'; }

template<typename T>
void print(const vector<vector<T>> &t) {
    for (const auto &row : t) {
        print(row);
    }
}

template<typename T>
void print(const T &t) { cout << t << ' '; }

template<typename T, typename ...Args>
void print(const T &t, const Args &...rest) {
    print(t);
    print(rest...);
}

template<typename T>
void println(const T &t) { cout << t << '\n'; }

template<typename T, typename ...Args>
void println(const T &t, const Args &...rest) {
    print(t);
    println(rest...);
}

template<typename T>
istream &operator>>(istream &stream, vector<T> &vec) {
    for (auto &x : vec) stream >> x;
    return stream;
}

void scan() {}

template<class T, class ...Args>
void scan(T &a, Args &...rest) {
    cin >> a;
    scan(rest...);
}

using ull = unsigned long long;
using ll = long long;
using ul = unsigned long;
using vl = vector<ll>;
using vi = vector<int>;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pip = pair<int, pii>;
using pll = pair<ll, ll>;
using vb = vector<bool>;
using vpii = vector<pii>;
using ldb = long double;

template<typename int_t>
inline int_t lowbit(int_t x) { return x & -x; }

#if __cplusplus < 201402L
template<class Iterator>
std::reverse_iterator<Iterator> make_reverse_iterator(Iterator it) {
    return std::reverse_iterator<Iterator>(it);
}
#endif

template<typename iter_t>
struct iter_pair {
    iter_t _beg, _end;

    iter_t begin() { return _beg; }

    iter_t end() { return _end; }
};

template<class cont>
iter_pair<reverse_iterator<decltype(begin(declval<cont>()))>>
reverse(cont &&r) {
    return {make_reverse_iterator(end(r)), make_reverse_iterator(begin(r))};
}

#define rng(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define up(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define down(i, b, a) for (int i = int(b); i >= int(a); i--)
#define rep(n) for(int _iter_##n = 0, _num_##n = (int)n; _iter_##n < _num_##n; ++_iter_##n)
#define FOR(x, cont) for (const auto &x: cont)
#define For(x, cont) for (auto &x: cont)
#define all(x) begin(x), end(x)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ep emplace
#define SZ(x) (int)(x).size()
template<typename T, typename Comp = less<T>>
using pq = priority_queue<T, vector<T>, Comp>;
#define popcnt(x) __builtin_popcountll((x))
#define UNIQ(vec) (vec).erase(unique(all(vec)), end(vec))
#define LB(cont, x) int(lower_bound(ALL(cont), x) - begin(cont))
#define UB(cont, x) int(upper_bound(all(cont), x) - begin(cont))
const int dx[] = {0, 0, -1, 1}, dy[] = {-1, 1, 0, 0};
const int dx8[] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy8[] = {-1, 0, 1, -1, 1, -1, 0, 1};
auto bet = [](const ll x, const ll y, const ll i) {
    return x <= i && i <= y;
};

template<typename T1, typename T2>
T1 ceil(T1 x, T2 y) { // y >= 1，是整数。需要注意 x + y - 1 是否会溢出
    return (x + y - 1) / y;
}

inline int h_bit(unsigned long long x) {
    return (int) sizeof(unsigned long long) * 8 - 1 - __builtin_clzll(x);
}

unsigned long long pow2(unsigned long long x) { // round up to power of 2
    return 1ull << (h_bit((ull) x) + (x != lowbit(x)));
}

template<typename T>
class BIT {
    vector<T> a;
    using BinOp = function<T(T, T)>;
    BinOp bin_op;
    const T init;
public:
    explicit BIT(int n, BinOp op = [](T x, T y) { return x + y; }, T init = T{})
            : bin_op(op), init(init), a(n + 1, init) {}

    T prefix(int x) const {
        auto res = init;
        while (x) {
            res = bin_op(a[x], res);
            x -= x & -x;
        }
        return res;
    }

    void modify(int x, T v) {
        while (x < (int) a.size()) {
            a[x] = bin_op(a[x], v);
            x += x & -x;
        }
    }

    void clear() {
        fill(a.begin(), a.end(), init);
    }
};

vi get_prime(int n) {
    vi minp((ul) n + 1), p;
    for (int i = 2; i <= n; i++) {
        if (!minp[i]) {
            minp[i] = i;
            p.pb(i);
        }
        FOR(x, p) {
            if (x <= minp[i] && x * i <= n)
                minp[x * i] = x;
            else break;
        }
    }
    return p;
}

// alias templates
template<typename T> using vv = vector<vector<T>>;
template<typename T1, typename T2 = T1> using vp = vector<pair<T1, T2>>;
template<typename T, int n> using va = vector<array<T, n>>;

//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).
#ifdef __GNUC__

#include <ext/pb_ds/assoc_container.hpp>

template<typename T, typename comp = less<T>>
using order_set = __gnu_pbds::tree<
        T,
        __gnu_pbds::null_type,
        comp,
        __gnu_pbds::rb_tree_tag,
        __gnu_pbds::tree_order_statistics_node_update>;

#include <ext/pb_ds/trie_policy.hpp>

using trie = __gnu_pbds::trie<string, __gnu_pbds::null_type>;
#endif

class UnionFind {
    vi par, sz;
    int nTree;
public:
    explicit UnionFind(int n) : par(n), sz(n, 1), nTree(n) { //0-indexed
        iota(par.begin(), par.end(), 0);
    }

    int n_tree() const {
        return nTree;
    }

    int size(int x) {
        return sz[root(x)];
    }

    int root(int x) {
        return x == par[x] ? x : par[x] = root(par[x]);
    }

    bool unite(int x, int y) {
        int rx = root(x), ry = root(y);
        if (rx != ry) {
            par[rx] = ry;
            --nTree;
            sz[ry] += sz[rx];
            return true;
        }
        return false;
    }

    bool is_root(int x) const {
        return par[x] == x;
    }
};

template<typename T, typename Compare = std::less<T>>
struct SparseTable {
    size_t n{}; // 0-indexed
    vv<T> a;

    template<typename ptr_t>
    SparseTable(ptr_t beg, ptr_t end):n(end - beg) {
        a.resize((size_t) h_bit(n) + 1); // 注意：不能写成 h_bit(n)
        a[0].assign(beg, end);
        rng (i, 0, SZ(a) - 1) {
            a[i + 1].resize(n);
            rng(j, 0, n - (1u << i)) {
                a[i + 1][j] = min(a[i][j], a[i][j + (1u << i)], Compare());
            }
            rng(j, n - (1u << i), n) {
                a[i + 1][j] = a[i][j];
            }
        }
    }

    using idx_t = long;

    T query(idx_t l, idx_t r) { // l <=  r
        int i = h_bit(r - l + 1ul);
        return min(a[i][l], a[i][r + 1 - (1u << i)], Compare());
    }
};

// debug code by tourist
string to_string(const string &s) {
    return '"' + s + '"';
}

string to_string(const char *s) {
    return to_string((string) s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

template<typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template<typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }

template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

// end DEBUG
template<typename T, typename Compare>
class MonoQueue {
private:
    deque<pair<T, int>> que;
    Compare cmp;
public:
    void push(const T &val, int i) {
        while (!que.empty() && !cmp(que.back().first, val)) {
            que.pop_back();
        }
        que.emplace_back(val, i);
    }

    T get(int i) {
        while (que.front().second < i) {
            que.pop_front();
        }
        return que.front().first;
    }
};

template<typename T>
struct Binom {
    vector<T> fact, inv_fact;

    explicit Binom(int n) : fact(n + 1), inv_fact(n + 1) {
        fact[0] = 1;
        up (i, 1, n) fact[i] = fact[i - 1] * i;
        inv_fact[n] = 1 / fact[n];
        down (i, n, 1) {
            inv_fact[i - 1] = inv_fact[i] * i;
        }
    }

    T get_binom(int x, int y) const {
        assert(x <= SZ(fact) - 1);
        assert(x >= 0 && y >= 0);
        if (x < y) return 0;
        return fact[x] * inv_fact[y] * inv_fact[x - y];
    }

    T get_fact(int n) const {
        assert(n < SZ(fact));
        return fact[n];
    }
};

template<typename T>
T get_mid(T l, T r) {
    assert(l <= r);
    return l + (r - l) / 2;
}

template<typename T>
int get_bit(T a, int i) {
    return a >> i & 1;
}

// ftiasch's implementation of segment tree
int get_id(int l, int r) {
    assert(0 <= l && l <= r);
    // 叶子的下标是 0, 2, 4, ..., 2*(n-1)
    return l + r | (l != r);
}

/*using ModType = int;

  struct VarMod {
  static ModType value;
  };
  ModType VarMod::value;
  ModType &md = VarMod::value;
  using Mint = Modular<VarMod>;*/
constexpr int md = 998244353;
using Mint = Modular<std::integral_constant<decay<decltype(md)>::type, md>>;
//////////////////^"^///////////////////////////////////

// 仿照 ftiasch 的写法
template<typename T>
struct Mat {
    array<array<T, 2>, 2> m;

    array<T, 2> &operator[](int i) {
        return m[i];
    }

    const array<T, 2> &operator[](int i) const {
        return m[i];
    }

    Mat operator*(const Mat b) {
        Mat c;
        rng (i, 0, 2) {
            rng (j, 0, 2) {
                rng (k, 0, 2) {
                    c[i][j] += m[i][k] * b[k][j];
                }
            }
        }
        return c;
    }
};

struct Frac {
    int p, q;
    operator Mint() {
        assert(q != 0);
        return p / Mint(q);
    }
};

bool operator<(const Frac &a, const Frac &b) {
    return 1ll * a.p * b.q < 1ll * b.p * a.q;
}

int main() {
#if defined LOCAL && !defined DUIPAI
    ifstream in("in.txt");
    cin.rdbuf(in.rdbuf());
#endif
    int n;
    scan(n);
    if (n == 1) {
        println(0);
        return 0;
    }
    vi x(n), v(n);
    vector<Mint> p(n);
    Mint inv_100 = 1 / Mint(100);
    rng (i, 0, n) {
        scan(x[i], v[i], p[i]);
        p[i] *= inv_100;
    }

    vector<Mat<Mint>> allowed_collisions(n - 1);
    // 0: left, 1: right
    rng (i, 0, n - 1) {
        allowed_collisions[i][0][1] = p[i + 1];
    }

    // segment tree
    vector<Mat<Mint>> a(2 * (n - 1) - 1);
    auto get_prob = [to_right = p[0], &mat = a[get_id(0, n - 2)]]() {
        return to_right * (mat[1][0] + mat[1][1]) + (1 - to_right) * (mat[0][0] + mat[0][1]);
    };
    function<void(int l, int r)> build = [&](int l, int r) {
        if (l == r) {
            a[2 * l] = allowed_collisions[l];
            return;
        }
        int mid = get_mid(l, r);
        build(l, mid);
        build(mid + 1, r);
        a[get_id(l, r)] = a[get_id(l, mid)] * a[get_id(mid + 1, r)];
    };
    build(0, n - 2);
    function<void(int, int, int)> modify = [&](int l, int r, int k) {
        if (l == r) {
            a[2 * l] = allowed_collisions[k];
            return;
        }
        int mid = get_mid(l, r);
        if (k <= mid) {
            modify(l, mid, k);
        } else {
            modify(mid + 1, r, k);
        }
        a[get_id(l, r)] = a[get_id(l, mid)] * a[get_id(mid + 1, r)];
    };
    vector<pair<Frac, int>> events(3 * (n - 1));

    rng (i, 0, n - 1) {
        int d = x[i + 1] - x[i];
        events[i * 3] = {{d, v[i + 1] + v[i]}, i << 2 | 1};
        events[i * 3 + 1] = {
                v[i] < v[i + 1] ? Frac{d, v[i + 1] - v[i]} : Frac{1, 0}, i << 2 | 0};
        events[i * 3 + 2] = {
                v[i] > v[i + 1] ? Frac{d, v[i] - v[i + 1]} : Frac{1, 0}, i << 2 | 3};
    }

    sort(all(events));

    Mint prev_prob = get_prob(), ans = 0;

    FOR (event, reverse(events)) {
        int i = event.second >> 2;
        int dir1 = get_bit(event.second, 0);
        int dir2 = get_bit(event.second, 1);
        // allow this collision of the i-th and i+1-t proton to happen
        allowed_collisions[i][dir1][dir2] = dir2 ? p[i + 1] : 1 - p[i + 1];
        modify(0, n - 2, i);
        Mint prob = get_prob();
        if (event.first.q != 0) {
            ans += (prob - prev_prob) * event.first;
        }
        prev_prob = prob;
    }

    println(ans);

#if defined LOCAL && !defined DUIPAI
    cout << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int n,leve,INV100,mod=998244353;
#define maxn 100011
#define maxeve maxn*3
struct Poi
{
	int x,v,p;
}a[maxn];
struct Eve
{
	int id,a,b,timemod; double time;
	bool operator < (const Eve &b) const {return time<b.time;}
}eve[maxeve];

int powmod(int a,int b)
{
	int ans=1;
	while (b)
	{
		if (b&1) ans=1ll*ans*a%mod;
		a=1ll*a*a%mod;
		b>>=1;
	}
	return ans;
}

double calc(int i,int x,int y)
{
	int v1,v2;
	if (x) v1=a[i-1].v; else v1=-a[i-1].v;
	if (y) v2=a[i].v; else v2=-a[i].v;
	return 1.0*(a[i].x-a[i-1].x)/(v1-v2);
}

int calcmod(int i,int x,int y)
{
	int v1,v2;
	if (x) v1=a[i-1].v; else v1=-a[i-1].v;
	if (y) v2=a[i].v; else v2=-a[i].v;
	return ((0ll+a[i].x-a[i-1].x+mod)%mod)*1ll*powmod((0ll+v1-v2+mod+mod)%mod,mod-2)%mod;
}

struct smtnode{int ls,rs,v[2][2];};
struct SMT
{
	smtnode a[maxn<<1];
	int n,sz;
	void clear(int N) {n=N; sz=0;}
	void up(int x)
	{
		int p=a[x].ls,q=a[x].rs;
		for (int i=0;i<2;i++)
			for (int j=0;j<2;j++)
			{
				a[x].v[i][j]=0;
				for (int k=0;k<2;k++)
					a[x].v[i][j]=(a[x].v[i][j]+1ll*a[p].v[i][k]*a[q].v[k][j])%mod;
			}
	}
	void build(int &x,int L,int R,Poi *b)
	{
		x=++sz;
		if (L==R)
		{
			a[x].ls=a[x].rs=0;
			a[x].v[0][1]=a[x].v[1][1]=b[L].p;
			a[x].v[0][0]=a[x].v[1][0]=mod+1-b[L].p;
			return;
		}
		int mid=(L+R)>>1;
		build(a[x].ls,L,mid,b);
		build(a[x].rs,mid+1,R,b);
		up(x);
	}
	void build(Poi *b) {int x; build(x,1,n,b);}
	int query() {return (0ll+a[1].v[0][0]+a[1].v[0][1])%mod;}
	void Modify(int x,int L,int R,int p,int q,int r)
	{
		if (L==R)
		{
			a[x].v[q][r]=0;
			return;
		}
		int mid=(L+R)>>1;
		if (p<=mid) Modify(a[x].ls,L,mid,p,q,r);
		else Modify(a[x].rs,mid+1,R,p,q,r);
		up(x);
	}
	void modify(int p,int q,int r) {Modify(1,1,n,p,q,r);}
}t;

int main()
{
	scanf("%d",&n);
	INV100=powmod(100,mod-2);
	for (int i=1;i<=n;i++) scanf("%d%d%d",&a[i].x,&a[i].v,&a[i].p),a[i].p=a[i].p*1ll*INV100%mod;

	//0 zuo 1 you

	leve=0;
	for (int i=2;i<=n;i++)
	{
		eve[++leve]={i,1,0,calcmod(i,1,0),calc(i,1,0)};
		if (a[i-1].v>a[i].v) eve[++leve]={i,1,1,calcmod(i,1,1),calc(i,1,1)};
		if (a[i-1].v<a[i].v) eve[++leve]={i,0,0,calcmod(i,0,0),calc(i,0,0)};
	}
	sort(eve+1,eve+1+leve);

	t.clear(n);
	t.build(a);
	int ans=0;
	for (int i=1,tmp,lastval=1;i<=leve;i++)
	{
		t.modify(eve[i].id,eve[i].a,eve[i].b);
		tmp=t.query();
		ans=(ans+(lastval-tmp+mod)*1ll*(eve[i].timemod))%mod;
		lastval=tmp;
	}
	printf("%d\n",ans);
	return 0;
}


# include <bits/stdc++.h>

/*
// ordered_set
# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
# define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
*/

using namespace std;

typedef long long                                        ll;
typedef long double                                      ld;
typedef pair <ll,  ll >                                  pii;
typedef pair <pii, ll >                                  ppi;
typedef pair <ll , pii>                                  pip;
typedef pair <pii, pii>                                  ppp;
typedef pair <ll, ll>                                    pll;

# define A                                               first
# define B                                               second
# define endl                                            '\n'
# define sep                                             ' '
# define all(x)                                          x.begin(), x.end()
# define kill(x)                                         return cout << x << endl, 0
# define SZ(x)                                           int(x.size())
# define Sort(x)                                         sort(all(x))
# define InTheNameOfGod                                  ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);

ll power(ll a, ll b, ll md) {return (!b ? 1 : (b & 1 ? a * power(a * a % md, b / 2, md) % md : power(a * a % md, b / 2, md) % md));}

const int xn = 1e5 + 10;
const int xm = 20 + 10;
const int SQ = 320;
const int sq = 320 + 10;
const int inf = 1e9 + 10;
const ll INF = 1e18 + 10;
const ll MOD = 998244353;
const int TM = 30;
const int BASE = 257;

ll n, num[xn], v[xn], p[xn], inv = power(100, MOD - 2, MOD), ans, flag, sum;
ppp seg[xn << 2];
bool mark[xn][4];
vector <ppp> vec;

void PRINT(ppp x){cout << x.A.A << sep << x.A.B << " , " << x.B.A << sep << x.B.B << endl;}
bool CMP(ppp x, ppp y){
	if (ld(ld(x.A.A) / ld(x.A.B)) != ld(ld(y.A.A) / ld(y.A.B))) return (ld(ld(x.A.A) / ld(x.A.B)) < ld(ld(y.A.A) / ld(y.A.B)));
	return x.B.A < y.B.A;
}
ppp merge(ppp x, ppp y, pii f, int ind, int g = 0){
	if (x.A.A == -1) return y;
	if (y.A.A == -1) return x;
	ppp z = {{0, 0}, {0, 0}};
	flag = (ind == f.A);
	if (mark[ind][0] == g || (f.B == 0 && g == 2)) z.A.A = (z.A.A + x.A.A * y.A.A) % MOD;
	if (mark[ind][1] == g || (f.B == 1 && g == 2)) z.A.A = (z.A.A + x.A.A * y.B.A) % MOD;
	if (mark[ind][2] == g || (f.B == 2 && g == 2)) z.A.A = (z.A.A + x.A.B * y.A.A) % MOD;
	if (mark[ind][3] == g || (f.B == 3 && g == 2)) z.A.A = (z.A.A + x.A.B * y.B.A) % MOD;
	if (mark[ind][0] == g || (f.B == 0 && g == 2)) z.A.B = (z.A.B + x.A.A * y.A.B) % MOD;
	if (mark[ind][1] == g || (f.B == 1 && g == 2)) z.A.B = (z.A.B + x.A.A * y.B.B) % MOD;
	if (mark[ind][2] == g || (f.B == 2 && g == 2)) z.A.B = (z.A.B + x.A.B * y.A.B) % MOD;
	if (mark[ind][3] == g || (f.B == 3 && g == 2)) z.A.B = (z.A.B + x.A.B * y.B.B) % MOD;
	if (mark[ind][0] == g || (f.B == 0 && g == 2)) z.B.A = (z.B.A + x.B.A * y.A.A) % MOD;
	if (mark[ind][1] == g || (f.B == 1 && g == 2)) z.B.A = (z.B.A + x.B.A * y.B.A) % MOD;
	if (mark[ind][2] == g || (f.B == 2 && g == 2)) z.B.A = (z.B.A + x.B.B * y.A.A) % MOD;
	if (mark[ind][3] == g || (f.B == 3 && g == 2)) z.B.A = (z.B.A + x.B.B * y.B.A) % MOD;
	if (mark[ind][0] == g || (f.B == 0 && g == 2)) z.B.B = (z.B.B + x.B.A * y.A.B) % MOD;
	if (mark[ind][1] == g || (f.B == 1 && g == 2)) z.B.B = (z.B.B + x.B.A * y.B.B) % MOD;
	if (mark[ind][2] == g || (f.B == 2 && g == 2)) z.B.B = (z.B.B + x.B.B * y.A.B) % MOD;
	if (mark[ind][3] == g || (f.B == 3 && g == 2)) z.B.B = (z.B.B + x.B.B * y.B.B) % MOD;
	return z;
}
void build(int id, int l, int r){
	if (r - l == 1){
		seg[id].A.A = inv * (100 - p[l]) % MOD;
		seg[id].B.B = inv * p[l] % MOD;
		return;
	}
	int mid = l + r >> 1;
	build(id << 1, l, mid);
	build(id << 1 | 1, mid, r);
	seg[id] = merge(seg[id << 1], seg[id << 1 | 1], {-1, -1}, mid - 1);
}
void update(int id, int l, int r, int pos, int f){
	int mid = l + r >> 1;
	if (pos < mid - 1) update(id << 1, l, mid, pos, f);
	if (pos > mid - 1) update(id << 1 | 1, mid, r, pos, f);
	seg[id] = merge(seg[id << 1], seg[id << 1 | 1], {pos, f}, mid - 1);
}
ppp get(int id, int l, int r, int ql, int qr){
	if (ql <= l && r <= qr) return seg[id];
	if (qr <= l || r <= ql) return {{-1, -1}, {-1, -1}};
	int mid = l + r >> 1;
	return merge(get(id << 1, l, mid, ql, qr), get(id << 1 | 1, mid, r, ql, qr), {-1, -1}, mid - 1);
}

int main(){
    InTheNameOfGod;

    cin >> n;
    for (int i = 0; i < n; ++ i) cin >> num[i] >> v[i] >> p[i];
    for (int i = 0; i < n - 1; ++ i){
    	ll x = num[i + 1] - num[i];
    	ll y = v[i] + v[i + 1];
    	vec.push_back({{x, y}, {i, 2}});
    	if (v[i] > v[i + 1]){
    		y = v[i] - v[i + 1];
    		vec.push_back({{x, y}, {i, 3}});
		}
		if (v[i] < v[i + 1]){
			y = v[i + 1] - v[i];
			vec.push_back({{x, y}, {i, 0}});
		}
	}
	build(1, 0, n);
	sort(all(vec), CMP);
	for (ppp b : vec){
		ll Time = b.A.A * power(b.A.B, MOD - 2, MOD) % MOD;
		ppp x = get(1, 0, n, 0, b.B.A + 1);
		ppp y = get(1, 0, n, b.B.A + 1, n);
		ppp z = merge(x, y, {b.B.A, b.B.B}, b.B.A, 2);
		sum = 0;
		sum = (sum + z.A.A) % MOD;
		sum = (sum + z.A.B) % MOD;
		sum = (sum + z.B.A) % MOD;
		sum = (sum + z.B.B) % MOD;
		ans = (ans + sum * Time % MOD) % MOD;
		mark[b.B.A][b.B.B] = true;
		update(1, 0, n, b.B.A, b.B.B);
	}
	cout << ans << endl;

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
const int MOD = 998244353;

class SegTree {
	private:
		struct El {
			int p[2][2]; // Probability that leftmost is L/R and rightmost is L/R
			El() {
				p[0][0] = 0;
				p[0][1] = 0;
				p[1][0] = 0;
				p[1][1] = 0;
			}
			static El id() {
				El res;
				res.p[0][0] = 1;
				res.p[1][1] = 1;
				return res;
			}
		};
		static El combine(const El& le, const El& ri) {
			El res;
			for (int a = 0; a < 2; ++a) {
				for (int b = 0; b < 2; ++b) {
					for (int i = 0; i < 2; ++i) {
						res.p[a][b] = (res.p[a][b] + (ll)le.p[a][i] * ri.p[i][b]) % MOD;
					}
				}
			}
			return res;
		}
		void update(int i) {
			for (i >>= 1; i > 0; i >>= 1) seg[i] = combine(seg[2*i], seg[2*i+1]);
		}

		vector<El> seg;
		int h = 1;
	public:
		SegTree(int n) {
			while(h < n) h *= 2;
			seg.resize(2*h, El::id());
		}

		int prob(int i, int a, int b) {
			i += h;
			El backup = seg[i];
			for (int x = 0; x < 2; ++x) {
				for (int y = 0; y < 2; ++y) {
					if (x != a || y != b) seg[i].p[x][y] = 0;
				}
			}
			update(i);

			ll res = (seg[1].p[0][0] + seg[1].p[0][1]) % MOD;

			seg[i] = backup;
			update(i);
			return res;
		}
		void setv(int i, int a, int b, int c, int d) {
			i += h;
			seg[i].p[0][0] = a;
			seg[i].p[0][1] = b;
			seg[i].p[1][0] = c;
			seg[i].p[1][1] = d;
			update(i);
		}
		void zero(int i, int a, int b) {
			i += h;
			seg[i].p[a][b] = 0;
			update(i);
		}
};

ll modPow(ll a, ll b) {
	if (b & 1) return a * modPow(a, b-1) % MOD;
	if (b > 0) return modPow(a*a % MOD, b / 2);
	return 1;
}

struct Atom {
	int xi, vi, pi;
};

struct Rat {
	ll a, b;

	// a / b < rhs.a / rhs.b?
	bool operator<(const Rat& rhs) const {
		return a * rhs.b < b * rhs.a;
	}
	ll modv() const { return a * modPow(b, MOD-2) % MOD; }
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n;
	cin >> n;

	SegTree seg(n);

	vector<Atom> atoms(n);
	for (auto& v : atoms) cin >> v.xi >> v.vi >> v.pi;

	const ll HI = modPow(100, MOD - 2);
	for (int i = 0; i < n; ++i) {
		int prob0 = (100 - atoms[i].pi) * HI % MOD;
		int prob1 = atoms[i].pi * HI % MOD;
		seg.setv(i, prob0, prob1, prob0, prob1);
	}

	vector<pair<Rat, pair<int, pair<int, int>>>> que;
	for (int i = 0; i+1 < n; ++i) {
		ll dist = atoms[i+1].xi - atoms[i].xi;
		for (int a = 0; a < 2; ++a) {
			for (int b = 0; b < 2; ++b) {
				ll vel = (a ? 1 : -1) * atoms[i].vi + (b ? -1 : 1) * atoms[i+1].vi;
				Rat r = {dist, vel};
				if (vel > 0) que.push_back({r, {i, {a, b}}}); // Collision eventually happens
			}
		}
	}
	sort(que.begin(), que.end());

	ll res = 0;
	for (auto pr : que) {
		ll t = pr.first.modv();
		int i = pr.second.first;
		int a = pr.second.second.first;
		int b = pr.second.second.second;

		ll prob = seg.prob(i+1, a, b);
		res = (res + prob * t) % MOD;
		seg.zero(i+1, a, b);

		// cerr << "event " << i << ' ' << a << ' ' << b << ": " << t << ' ' << prob << '\n';
	}
	cout << res << '\n';
}


#include<bits/stdc++.h>
#define ls ch[x][0]
#define rs ch[x][1]
#define ll long long
#define int ll
using namespace std;

inline ll read(){
	ll num=0,neg=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')neg=-1;c=getchar();}
	while(isdigit(c)){num=(num<<3)+(num<<1)+c-'0';c=getchar();}
	return num*neg;
}

const ll mod=998244353;
struct mat{
	int a[2][2];
	mat(){for(int i=0;i<=1;i++) for(int j=0;j<=1;j++) a[i][j]=0;}
}tree[200010<<2];

const ll INF=0x7f7f7f7f7f7f7f;
struct node{
	int pos,p1,p2,val;
	double t;
}side[800010];int cnt;
ll ans,x[200010],v[200010],p[200010],n;

bool cmp1(node x,node y){return x.t<y.t;}

inline ll qpow(ll x,ll k){
	ll res=1;
	while(k){
		if(k&1)res=res*x%mod;
		x=x*x%mod;k>>=1;
	}return res;
}
inline mat mul(mat x,mat y){
	mat res;
	for(int i=0;i<=1;i++)
	for(int j=0;j<=1;j++)
	for(int k=0;k<=1;k++)
		res.a[i][j]=(res.a[i][j]+x.a[i][k]*y.a[k][j]%mod)%mod;
	return res;
}
inline void insert(int pos,int p1,int p2){
	side[++cnt].pos=pos;
	side[cnt].p1=p1,side[cnt].p2=p2;
	if(p1==0&&p2==0){
		int tmp=v[pos]-v[pos-1];
		if(tmp>0) side[cnt].val=(x[pos]-x[pos-1])*qpow(tmp,mod-2)%mod,side[cnt].t=(x[pos]-x[pos-1])*1.0/tmp;
		else side[cnt].val=INF,side[cnt].t=1e20;
	}
	if(p1==0&&p2==1) side[cnt].val=INF,side[cnt].t=1e20;
	if(p1==1&&p2==0) side[cnt].val=(x[pos]-x[pos-1])%mod*qpow((v[pos]+v[pos-1])%mod,mod-2)%mod,side[cnt].t=(x[pos]-x[pos-1])*1.0/(v[pos-1]+v[pos]);
	if(p1==1&&p2==1){
		int tmp=v[pos-1]-v[pos];
		if(tmp>0) side[cnt].val=(x[pos]-x[pos-1])*qpow(tmp,mod-2)%mod,side[cnt].t=(x[pos]-x[pos-1])*1.0/tmp;
		else side[cnt].val=INF,side[cnt].t=1e20;
	}
}
inline void push_up(int x){tree[x]=mul(tree[x<<1],tree[x<<1|1]);}
inline void build(int l,int r,int x){
	if(l==r){
		tree[x].a[0][0]=tree[x].a[1][0]=(1-p[l]+mod)%mod;
		tree[x].a[0][1]=tree[x].a[1][1]=p[l];
		return;
	}int mid=l+r>>1;
	build(l,mid,x<<1),build(mid+1,r,x<<1|1);
	push_up(x);return;
}
inline void update(int u,int p1,int p2,int l,int r,int x){
	if(l==r){tree[x].a[p1][p2]=0;return;}
	int mid=l+r>>1;
	if(u<=mid) update(u,p1,p2,l,mid,x<<1);
	else update(u,p1,p2,mid+1,r,x<<1|1);
	push_up(x);return;
}
inline mat query(int ql,int qr,int l,int r,int x){
	if(ql>qr){
		mat res;res.a[0][0]=res.a[1][1]=1;
		return res;
	}
	if(ql<=l&&qr>=r) return tree[x];
	int mid=l+r>>1;mat res;res.a[0][0]=res.a[1][1]=1;
	if(ql<=mid) res=mul(res,query(ql,qr,l,mid,x<<1));
	if(qr>mid) res=mul(res,query(ql,qr,mid+1,r,x<<1|1));
	return res;
}

signed main(){
	n=read();
	for(int i=1;i<=n;i++) x[i]=read(),v[i]=read(),p[i]=read()*qpow(100ll,mod-2)%mod;
	build(1,n,1);
	for(int i=2;i<=n;i++) for(int j=0;j<=1;j++) for(int k=0;k<=1;k++) insert(i,j,k);
	sort(side+1,side+cnt+1,cmp1);

	for(int i=1;i<=cnt;i++){
		if(side[i].val==INF) break;
		mat trans;
		trans.a[side[i].p1][side[i].p2]=(side[i].p2?p[side[i].pos]:(1-p[side[i].pos]+mod)%mod);
		trans=mul(query(1,side[i].pos-1,1,n,1),trans);
		trans=mul(trans,query(side[i].pos+1,n,1,n,1));
		ans+=(trans.a[0][0]+trans.a[0][1])%mod*side[i].val%mod;ans%=mod;
		update(side[i].pos,side[i].p1,side[i].p2,1,n,1);
	}printf("%lld\n",ans);return 0;
}


#include<cstdio>
#include<algorithm>
struct Element{
    int p,mask;
    long long uv, dv;
    Element(int p=0,int mask=0,long long uv=0,long long dv=0):
    p(p),mask(mask),uv(uv),dv(dv){}
    bool operator < (const Element& other)const{
        return uv*other.dv<other.uv*dv;
    }
};
struct SegmentT{
    int l,r;
    long long value[4];
};
const long long mod = 998244353;
long long x[100005], v[100005], p[100005];
long long prob[100005][2];
Element meet[400005];
long long need[100005][4];
SegmentT t[800005];

long long power(long long a,long long b){
    long long res = 1;
    while(b){
        if(b&1) res = res*a%mod;
        a = a*a%mod;
        b /= 2;
    }
    return res;
}

long long inv(long long u){ return power(u,mod-2); }

long long gcd(long long a,long long b){ return b?gcd(b,a%b):a; }

SegmentT merge(SegmentT& a, SegmentT& b){
    SegmentT res;
    res.l = a.l, res.r = b.r;
    for(int i = 0; i < 4; i++) res.value[i] = 0;
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 4; j++){
            int middle = (i%2)*2+j/2;
            int next = i/2*2+j%2;
            res.value[next] = res.value[next]+a.value[i]*b.value[j]*need[a.r][middle]%mod;
            if(res.value[next]>=mod) res.value[next] -= mod;
        }
    }
    return res;
}

void build(int p,int l,int r){
    t[p].l = l, t[p].r = r;
    if(l==r){
        t[p].value[1] = t[p].value[2] = 0;
        t[p].value[0] = prob[l][0];
        t[p].value[3] = prob[l][1];
    }
    else{
        int m = (l+r)/2;
        build(2*p,l,m);
        build(2*p+1,m+1,r);
        t[p] = merge(t[2*p],t[2*p+1]);
    }
}

void change(int p,int x){
    if(t[p].l==t[p].r) return ;
    else{
        int m = (t[p].l+t[p].r)/2;
        if(x<=m) change(2*p,x);
        if(x+1>m) change(2*p+1,x);
        t[p] = merge(t[2*p],t[2*p+1]);
    }
}

int main(){
    int n;
    scanf("%d",&n);
    long long inv100 = inv(100ll);
    for(int i = 1; i <= n; i++){
        scanf("%lld%lld%lld",&x[i],&v[i],&p[i]);
        prob[i][0] = (100ll-p[i])*inv100%mod;
        prob[i][1] = p[i]*inv100%mod;
        for(int j = 0; j < 4; j++) need[i][j] = 1;
    }
    build(1,1,n);
    //printf("res = %lld\n",res);
    int size = 0;
    for(int i = 1; i <= n-1; i++){
        int j = i+1;
        long long dis = x[j]-x[i];
        //i is 2, j is 1
        //0 is left, 1 is right
        for(int mask = 0; mask < 4; mask++){
            long long vi = v[i], vj = v[j];
            if(mask&2) vi *= -1;
            if(mask&1) vj *= -1;
            long long diffv = vj-vi;
            if(diffv>0){
                long long g = gcd(dis,diffv);
                meet[++size] = Element(i,mask,dis/g,diffv/g);
            }
        }
    }
    std::sort(meet+1,meet+1+size);
    long long ans = 0, curProb = 1;
    int p = 1;
    while(p<=size){
        int np = p;
        while(np+1<=size && meet[np+1].uv==meet[p].uv && meet[np+1].dv==meet[p].dv) np++;
        long long lastProb = curProb;
        for(int i = p; i <= np; i++){
            need[meet[i].p][meet[i].mask] = 0;
            change(1,meet[i].p);
        }
        curProb = 0;
        for(int i = 0; i < 4; i++){
            curProb += t[1].value[i];
            if(curProb>=mod) curProb -= mod;
        }
        long long midProb = lastProb-curProb;
        if(midProb<0) midProb += mod;
        long long time = meet[p].uv*inv(meet[p].dv)%mod;
        ans += midProb*time%mod;
        if(ans>=mod) ans -= mod;
        p = np+1;
    }
    printf("%lld\n",ans);
    return 0;
}


#include <iostream>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <climits>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#include <bitset>
#include <fstream>
#include <tr1/unordered_map>
#include <assert.h>

#define x first
#define y second
#define y0 Y0
#define y1 Y1
#define mp make_pair
#define pb push_back
#define DEBUG(x) cout << #x << " = " << x << endl;

using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair <int, int> pii;

template <typename T> inline int Chkmax (T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline int Chkmin (T &a, T b) { return a > b ? a = b, 1 : 0; }
template <typename T> inline T read ()
{
	T sum = 0, fl = 1; char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fl = -1;
	for (; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + ch - '0';
	return sum * fl;
}

inline void proc_status ()
{
	ifstream t ("/proc/self/status");
	cerr << string (istreambuf_iterator <char> (t), istreambuf_iterator <char> ()) << endl;
}

const int MAXN = 1e5;
const int MOD = 998244353;

namespace MATH
{
	inline void ADD (int &a, int b) { if ((a += b) >= MOD) a -= MOD; }

	inline int Pow (int a, int b)
	{
		int ans = 1;
		for (int i = b; i; i >>= 1, a = (LL) a * a % MOD) if (i & 1) ans = (LL) ans * a % MOD;
		return ans;
	}
}

using namespace MATH;

int N;
struct info
{
	int x, v, p;

	inline void read () { x = ::read<int>(), v = ::read<int>(), p = (LL) ::read<int>() * Pow (100, MOD - 2) % MOD; }

} A[MAXN + 5];

struct matrix // 右1左0
{
	int A[2][2];

	inline matrix () { memset (A, 0, sizeof A); }

	inline int* operator [] (const int &x) { return A[x]; }

	inline matrix operator * (const matrix &rhs) const
	{
		matrix now;
		for (int i = 0; i < 2; ++i)
			for (int k = 0; k < 2; ++k) if (A[i][k])
				for (int j = 0; j < 2; ++j)
					ADD (now.A[i][j], (LL) A[i][k] * rhs.A[k][j] % MOD);
		return now;
	}
};

namespace SEG
{
#define mid ((l + r) >> 1)
#define ls o << 1
#define rs o << 1 | 1
#define lson ls, l, mid
#define rson rs, mid + 1, r
	const int MAX_NODE = MAXN * 4;

	matrix node[MAX_NODE + 5];

	inline void push_up (int o) { node[o] = node[ls] * node[rs]; }

	inline void build (int o, int l, int r)
	{
		if (l == r)
		{
			int p = A[l].p;
			node[o][0][0] = node[o][1][0] = (1 - p + MOD) % MOD;
			node[o][0][1] = node[o][1][1] = p;
			return ;
		}
		build (lson), build (rson);
		push_up (o);
	}

	inline void modify (int o, int l, int r, int x, int s0, int s1)
	{
		if (l == r) { node[o][s0][s1] = 0; return ; }
		if (x <= mid) modify (lson, x, s0, s1);
		else modify (rson, x, s0, s1);
		push_up (o);
	}

	inline int query () { return (node[1][0][0] + node[1][0][1]) % MOD; }

#undef mid
}

struct point
{
	int x, s0, s1, t;
	LD tt;

	inline point (int _x = 0, int _s0 = 0, int _s1 = 0, int _t = 0, LD _tt = 0) { x = _x, s0 = _s0, s1 = _s1, t = _t, tt = _tt; }
};

inline int cmp_t (point a, point b) { return a.tt < b.tt; }

vector <point> vec;

inline void Init ()
{
	for (int i = 1; i < N; ++i)
	{
		info l = A[i], r = A[i + 1];
		if (l.p != 0 && r.p != 1)
			vec.pb (point (i + 1, 1, 0, (LL) (r.x - l.x) * Pow (l.v + r.v, MOD - 2) % MOD, (LD) (r.x - l.x) / (l.v + r.v)));
		if (l.p != 0 && r.p != 0 && l.v > r.v)
			vec.pb (point (i + 1, 1, 1, (LL) (r.x - l.x) * Pow (l.v - r.v, MOD - 2) % MOD, (LD) (r.x - l.x) / (l.v - r.v)));
		if (l.p != 1 && r.p != 1 && l.v < r.v)
			vec.pb (point (i + 1, 0, 0, (LL) (r.x - l.x) * Pow (r.v - l.v, MOD - 2) % MOD, (LD) (r.x - l.x) / (r.v - l.v)));
	}

	sort (vec.begin(), vec.end(), cmp_t);

	SEG :: build (1, 1, N);
}

inline void Solve ()
{
	if (N == 1) return void (puts("0"));
	Init ();

	int ans = 0, lst = 1;
	for (int i = 0; i < vec.size(); ++i)
	{
		int x = vec[i].x, s0 = vec[i].s0, s1 = vec[i].s1, t = vec[i].t;
		SEG :: modify (1, 1, N, x, s0, s1);
		int p = (lst - SEG :: query () + MOD) % MOD;
		ADD (ans, (LL) p * t % MOD);
		lst = SEG :: query ();
	}

	cout << ans << endl;
}

inline void Input ()
{
	N = read<int>();
	for (int i = 1; i <= N; ++i) A[i].read();
}

int main ()
{

#ifdef hk_cnyali
	freopen("F.in", "r", stdin);
	freopen("F.out", "w", stdout);
#endif

	Input ();
	Solve ();

	return 0;
}


#include<bits/stdc++.h>
#define mz 998244353
using namespace std;

struct Mat
{
    long long num[2][2];
    Mat ()
    {
        num[0][0]=num[0][1]=num[1][0]=num[1][1]=1;
    }
    Mat (long long a)
    {
        num[0][0]=num[0][1]=a;
        num[1][0]=0;
        num[1][1]=(1+mz-a)%mz;
    }
    Mat friend operator *(Mat x1,Mat x2)
    {
        Mat x3;
        x3.num[0][0]=(x1.num[0][0]*x2.num[0][0]+x1.num[0][1]*x2.num[1][0])%mz;
        x3.num[0][1]=(x1.num[0][0]*x2.num[0][1]+x1.num[0][1]*x2.num[1][1])%mz;
        x3.num[1][0]=(x1.num[1][0]*x2.num[0][0]+x1.num[1][1]*x2.num[1][0])%mz;
        x3.num[1][1]=(x1.num[1][0]*x2.num[0][1]+x1.num[1][1]*x2.num[1][1])%mz;
        return x3;
    }
}mp;
struct Point
{
    long long v,x;
    int no,k;
    bool friend operator <(Point x1,Point x2)
    {
        if(x1.x*x2.v==x2.x*x1.v)
            return x1.no<x2.no;
        return (x1.x*x2.v)>(x2.x*x1.v);
    }
}pp;
struct Node
{
    int l,r,mid;
	Mat m;
}tre[400005];
long long p[100005],x[100005],v[100005],ni;
priority_queue <Point> pq;

long long ksm(long long x)
{
    long long z=1,y=mz-2;
    while(y)
    {
        if(y%2)
            z=(z*x)%mz;
        y>>=1;
        x=(x*x)%mz;
    }
    return z;
}
void build(int x,int l,int r)
{
	tre[x].l=l;
	tre[x].r=r;
	tre[x].mid=(l+r)/2;
	if(l==r)
	{
		tre[x].m.num[0][0]=tre[x].m.num[0][1]=(1+mz-p[l])%mz;
		tre[x].m.num[1][0]=tre[x].m.num[1][1]=p[l];
	}
	else
	{
		build(x*2,l,tre[x].mid);
		build(x*2+1,tre[x].mid+1,r);
		tre[x].m=tre[x*2].m*tre[x*2+1].m;
	}
}
Mat ask(int x,int l,int r)
{
	if(tre[x].l==l && r==tre[x].r)
		return tre[x].m;
	else if(r<=tre[x].mid)
		return ask(x*2,l,r);
	else if(l>tre[x].mid)
		return ask(x*2+1,l,r);
	return ask(x*2,l,tre[x].mid)*ask(x*2+1,tre[x].mid+1,r);
}
void change(int x,int y,int k)
{
	if(tre[x].l==tre[x].r)
	{
		if(k==1)
			tre[x].m.num[1][0]=0;
		if(k==2)
			tre[x].m.num[0][0]=0;
		if(k==3)
			tre[x].m.num[1][1]=0;
	}
	else
	{
		if(y<=tre[x].mid)
			change(x*2,y,k);
		else
			change(x*2+1,y,k);
		tre[x].m=tre[x*2].m*tre[x*2+1].m;
	}
}

int main()
{
    int n;
    ni=ksm(100);
    long long ans=0,tp,pl,pr,ppl,ppr;
    scanf("%d",&n);
    scanf("%lld%lld%lld",&x[1],&v[1],&p[1]);
    p[1]=(p[1]*ni)%mz;
    for(int i=1;i<n;i++)
    {
        pp.no=i;
        scanf("%lld%lld%lld",&x[i+1],&v[i+1],&p[i+1]);
        p[i+1]=(p[i+1]*ni)%mz;
        pp.x=x[i+1]-x[i];
		pp.k=1;
        pp.v=v[i]+v[i+1];
        pq.push(pp);
        if(v[i]<v[i+1])
        {
        	pp.k=2;
	        pp.v=v[i+1]-v[i];
	        pq.push(pp);
		}
		if(v[i]>v[i+1])
        {
        	pp.k=3;
	        pp.v=v[i]-v[i+1];
	        pq.push(pp);
		}
    }
    build(1,0,n);
    while(!pq.empty())
    {
    	pp=pq.top();
    	pq.pop();
    	tp=(pp.x*ksm(pp.v))%mz;
    	mp=ask(1,pp.no+1,n);
    	pl=mp.num[0][0];
    	pr=mp.num[1][0];
    	ppl=ppr=0;
    	if(pp.k==1)
    		ppr=(pl*p[pp.no])%mz;
		if(pp.k==2)
    		ppl=(pl*(1+mz-p[pp.no]))%mz;
		if(pp.k==3)
			ppr=(pr*p[pp.no])%mz;
    	mp=ask(1,0,pp.no-1);
    	pl=(ppl*mp.num[0][0]+ppr*mp.num[0][1])%mz;
    	pr=(ppl*mp.num[1][0]+ppr*mp.num[1][1])%mz;
    	ans=(ans+tp*(pl+pr))%mz;
    	change(1,pp.no,pp.k);
	}
	printf("%lld\n",ans);
	return 0;
}


#include <bits/stdc++.h>
#define N 100000 + 5
#define MOD 998244353
#define inf 0x7fffffff
using namespace std;
struct P
{
    int id, x1, x2, x, v;
};
struct Matrix
{
    int op[3][3];
    void toE()
    {
        op[1][1] = op[2][2] = 1, op[1][2] = op[2][1] = 0;
    }
    void operator*=(const Matrix& s)
    {
        int tmp[3][3];
        tmp[1][1] = tmp[1][2] = tmp[2][1] = tmp[2][2] = 0;
        for (int i = 1; i <= 2; i++) {
            for (int j = 1; j <= 2; j++) {
                for (int k = 1; k <= 2; k++) tmp[i][j] = (tmp[i][j] + 1ll * op[i][k] * s.op[k][j]) % MOD;
            }
        }
        op[1][1] = tmp[1][1], op[1][2] = tmp[1][2], op[2][1] = tmp[2][1], op[2][2] = tmp[2][2];
    }
} nd[N << 2], t1, t2, t3, t4;
vector<P> vec;
int n, x[N], v[N], p[N], ans;
inline int inv(int x)
{
    int ans = 1, sta = x, y = MOD - 2;
    while (y) {
        if (y & 1) ans = 1ll * ans * sta % MOD;
        sta = 1ll * sta * sta % MOD, y >>= 1;
    }
    return ans;
}
void getTime(int a, int b, int id, int& xx, int& vv)
{
    int t = 0;
    if (id == 0) {
        if (v[a] > v[b])
            xx = (x[b] - x[a]), vv = v[a] - v[b];
        else
            xx = inf;
    }
    else if (id == 3) {
        if (v[b] > v[a])
            xx = x[b] - x[a], vv = v[b] - v[a];
        else
            xx = inf;
    }
    else if (id == 1) {
        xx = x[b] - x[a], vv = v[a] + v[b];
    }
    else
        xx = inf;
}
void build(int l = 1, int r = n, int k = 1)
{
    if (l == r) {
        nd[k].op[1][1] = nd[k].op[2][1] = 1ll * (100 - p[l]) * inv(100) % MOD;
        nd[k].op[1][2] = nd[k].op[2][2] = 1ll * p[l] * inv(100) % MOD;
        return;
    }
    int mid = (l + r) >> 1;
    build(l, mid, k << 1), build(mid + 1, r, k << 1 | 1);
    nd[k].toE(), nd[k] *= nd[k << 1], nd[k] *= nd[k << 1 | 1];
}
void change(int at, const Matrix& s, int l = 1, int r = n, int k = 1)
{
    if (l == r) {
        nd[k] = s;
        return;
    }
    int mid = (l + r) >> 1;
    if (at <= mid)
        change(at, s, l, mid, k << 1);
    else
        change(at, s, mid + 1, r, k << 1 | 1);
    nd[k].toE(), nd[k] *= nd[k << 1], nd[k] *= nd[k << 1 | 1];
}
const Matrix& getMatrix(int at, int l = 1, int r = n, int k = 1)
{
    if (l == r) return nd[k];
    int mid = (l + r) >> 1;
    if (at <= mid) return getMatrix(at, l, mid, k << 1);
    return getMatrix(at, mid + 1, r, k << 1 | 1);
}

inline int get()
{
    return (nd[1].op[1][1] + nd[1].op[1][2]) % MOD;
}
int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d%d%d", x + i, v + i, p + i);
    for (int i = 2; i <= n; i++) {
        P ps;
        ps.x1 = i - 1, ps.x2 = i;
        for (int j = 0, pp; j < 4; j++) {
            getTime(i - 1, i, j, ps.x, ps.v);
            if (ps.x != inf) ps.id = j, vec.push_back(ps);
        }
    }
    sort(vec.begin(), vec.end(), [](P a, P b) {
        return 1ll * a.x * b.v < 1ll * b.x * a.v;
    });
    build();
    for (P s : vec) {
        t3 = t1 = getMatrix(s.x1), t4 = t2 = getMatrix(s.x2);
        if (s.id & 1)
            t2.op[1][2] = t2.op[2][2] = 0;
        else
            t2.op[1][1] = t2.op[2][1] = 0;
        if (s.id & 2)
            t1.op[1][2] = t1.op[2][2] = 0;
        else
            t1.op[1][1] = t1.op[2][1] = 0;
        change(s.x1, t1), change(s.x2, t2);
        ans = (ans + 1ll * s.x * inv(s.v) % MOD * get()) % MOD;
        if (s.id == 0)
            t4.op[2][2] = 0;
        else if (s.id == 1)
            t4.op[2][1] = 0;
        else if (s.id == 3)
            t4.op[1][1] = 0;
        change(s.x1, t3), change(s.x2, t4);
    }
    printf("%d", (ans + MOD) % MOD);
    // PAUSE;
    return 0;
}


#include<bits/stdc++.h>
#define ls ch[x][0]
#define rs ch[x][1]
#define ll long long
#define int ll
using namespace std;

inline ll read(){
	ll num=0,neg=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')neg=-1;c=getchar();}
	while(isdigit(c)){num=(num<<3)+(num<<1)+c-'0';c=getchar();}
	return num*neg;
}

const ll mod=998244353;
struct mat{
	int a[2][2];
	mat(){for(int i=0;i<=1;i++) for(int j=0;j<=1;j++) a[i][j]=0;}
}tree[200010<<2];

const ll INF=0x7f7f7f7f7f7f7f;
struct node{
	int pos,p1,p2,val;
	double t;
}side[800010];int cnt;
ll ans,x[200010],v[200010],p[200010],n;

bool cmp1(node x,node y){return x.t<y.t;}

inline ll qpow(ll x,ll k){
	ll res=1;
	while(k){
		if(k&1)res=res*x%mod;
		x=x*x%mod;k>>=1;
	}return res;
}
inline mat mul(mat x,mat y){
	mat res;
	for(int i=0;i<=1;i++)
	for(int j=0;j<=1;j++)
	for(int k=0;k<=1;k++)
		res.a[i][j]=(res.a[i][j]+x.a[i][k]*y.a[k][j]%mod)%mod;
	return res;
}
inline void insert(int pos,int p1,int p2){
	side[++cnt].pos=pos;
	side[cnt].p1=p1,side[cnt].p2=p2;
	if(p1==0&&p2==0){
		int tmp=v[pos]-v[pos-1];
		if(tmp>0) side[cnt].val=(x[pos]-x[pos-1])*qpow(tmp,mod-2)%mod,side[cnt].t=(x[pos]-x[pos-1])*1.0/tmp;
		else side[cnt].val=INF,side[cnt].t=1e20;
	}
	if(p1==0&&p2==1) side[cnt].val=INF,side[cnt].t=1e20;
	if(p1==1&&p2==0) side[cnt].val=(x[pos]-x[pos-1])%mod*qpow((v[pos]+v[pos-1])%mod,mod-2)%mod,side[cnt].t=(x[pos]-x[pos-1])*1.0/(v[pos-1]+v[pos]);
	if(p1==1&&p2==1){
		int tmp=v[pos-1]-v[pos];
		if(tmp>0) side[cnt].val=(x[pos]-x[pos-1])*qpow(tmp,mod-2)%mod,side[cnt].t=(x[pos]-x[pos-1])*1.0/tmp;
		else side[cnt].val=INF,side[cnt].t=1e20;
	}
}
inline void push_up(int x){tree[x]=mul(tree[x<<1],tree[x<<1|1]);}
inline void build(int l,int r,int x){
	if(l==r){
		tree[x].a[0][0]=tree[x].a[1][0]=(1-p[l]+mod)%mod;
		tree[x].a[0][1]=tree[x].a[1][1]=p[l];
		return;
	}int mid=l+r>>1;
	build(l,mid,x<<1),build(mid+1,r,x<<1|1);
	push_up(x);return;
}
inline void update(int u,int p1,int p2,int l,int r,int x){
	if(l==r){tree[x].a[p1][p2]=0;return;}
	int mid=l+r>>1;
	if(u<=mid) update(u,p1,p2,l,mid,x<<1);
	else update(u,p1,p2,mid+1,r,x<<1|1);
	push_up(x);return;
}
inline mat query(int ql,int qr,int l,int r,int x){
	if(ql>qr){
		mat res;res.a[0][0]=res.a[1][1]=1;
		return res;
	}
	if(ql<=l&&qr>=r) return tree[x];
	int mid=l+r>>1;mat res;res.a[0][0]=res.a[1][1]=1;
	if(ql<=mid) res=mul(res,query(ql,qr,l,mid,x<<1));
	if(qr>mid) res=mul(res,query(ql,qr,mid+1,r,x<<1|1));
	return res;
}

signed main(){
	n=read();
	for(int i=1;i<=n;i++) x[i]=read(),v[i]=read(),p[i]=read()*qpow(100ll,mod-2)%mod;
	build(1,n,1);
	for(int i=2;i<=n;i++) for(int j=0;j<=1;j++) for(int k=0;k<=1;k++) insert(i,j,k);
	sort(side+1,side+cnt+1,cmp1);

	for(int i=1;i<=cnt;i++){
		if(side[i].val==INF) break;
		mat trans;
		trans.a[side[i].p1][side[i].p2]=(side[i].p2?p[side[i].pos]:(1-p[side[i].pos]+mod)%mod);
		trans=mul(query(1,side[i].pos-1,1,n,1),trans);
		trans=mul(trans,query(side[i].pos+1,n,1,n,1));
		ans+=(trans.a[0][0]+trans.a[0][1])*side[i].val%mod;ans%=mod;
		update(side[i].pos,side[i].p1,side[i].p2,1,n,1);
	}printf("%lld\n",ans);return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
const int N=1e5+1,MOD=998244353;
int lim[N][2][2],p[N<<2][2][2],psb[N][2];
inline int qpow(int base,int expo)
{
	int ret=1;
	while(expo)
	{
		if(expo&1) ret=1ll*ret*base%MOD;
		base=1ll*base*base%MOD;
		expo>>=1;
	}
	return ret;
}
inline void up(int now,int mid)
{
	int i,j,k,l;
	for(i=0;i<2;i++)
	{
		for(j=0;j<2;j++)
		{
			p[now][i][j]=0;
			for(k=0;k<2;k++)
				for(l=0;l<2;l++)
					if(!lim[mid][k][l])
						p[now][i][j]=(0ll+p[now][i][j]+1ll*p[now<<1][i][k]*p[now<<1|1][l][j]%MOD)%MOD;
		}
	}
}
void build(int now,int l,int r)
{
	if(l==r)
	{
		p[now][0][0]=psb[l][0];
		p[now][1][1]=psb[l][1];
		return;
	}
	int mid=(l+r)>>1;
	build(now<<1,l,mid);
	build(now<<1|1,mid+1,r);
	up(now,mid);
}
void update(int now,int l,int r,int qp)
{
	if(l==r) return;
	int mid=(l+r)>>1;
	if(qp<=mid) update(now<<1,l,mid,qp);
	else update(now<<1|1,mid+1,r,qp);
	up(now,mid);
}
struct chase
{
	int x,xp,yp;
	double tim;
	int rtim;
	chase(int x=0,int xp=0,int yp=0,double tim=0,int rtim=0):
		x(x),xp(xp),yp(yp),tim(tim),rtim(rtim){}
} cs[N*2];
int csc;
inline int cmp(chase a,chase b){return a.tim<b.tim;}
int main()
{
	int n,i,lasp,lasv,inv=qpow(100,MOD-2);
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		int tpos,tv;
		scanf("%d%d%d",&tpos,&tv,&psb[i][1]);
		if(i>1)
		{
			int dis=tpos-lasp;
			cs[++csc]=chase(i-1,1,0,dis/1.0/(tv+lasv),1ll*dis*qpow(tv+lasv,MOD-2)%MOD);
			if(tv<lasv) cs[++csc]=chase(i-1,1,1,dis/1.0/(lasv-tv),1ll*dis*qpow(lasv-tv,MOD-2)%MOD);
			else if(tv>lasv) cs[++csc]=chase(i-1,0,0,dis/1.0/(tv-lasv),1ll*dis*qpow(tv-lasv,MOD-2)%MOD);
		}
		psb[i][0]=1ll*(100-psb[i][1])*inv%MOD;
		psb[i][1]=1ll*psb[i][1]*inv%MOD;
		lasp=tpos,lasv=tv;
	}
	build(1,1,n);
	sort(cs+1,cs+csc+1,cmp);
	int ans=0,lpsb=1;
	for(i=1;i<=csc;i++)
	{
		lim[cs[i].x][cs[i].xp][cs[i].yp]=1;
		update(1,1,n,cs[i].x);
		int tpsb=(0ll+p[1][0][0]+p[1][0][1]+p[1][1][0]+p[1][1][1])%MOD;
		ans=(0ll+ans+1ll*cs[i].rtim*(lpsb-tpsb+MOD)%MOD)%MOD;
		lpsb=tpsb;
	}
	printf("%d",ans);
	return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int MAXN=110000;
const int P=998244353;
const int INV100=828542813;
void exgcd(int a, int b, int& x, int& y)
{
	if (b==0) x=1, y=0;
	else exgcd(b, a%b, y, x), y-=a/b*x;
}
inline int inv(int a)
{
	int x, y;
	exgcd(a, P, x, y);
	return (x%P+P)%P;
}
struct Matrix
{
	int n, m, a[3][3];
	Matrix() {}
	Matrix(int r, int c): n(r), m(c)
	{
		memset(a, 0, sizeof a);
	}
	Matrix operator * (const Matrix& b) const
	{
		Matrix c(n, b.m);
		for (int i=0; i<n; i++)
			for (int k=0; k<m; k++)
				for (int j=0; j<b.m; j++)
					c.a[i][j]=(c.a[i][j]+1ll*a[i][k]*b.a[k][j])%P;
		return c;
	}
} w[MAXN];
struct SegmenTree
{
	struct Node
	{
		int l, r;
		Matrix val;
	} tr[4*MAXN];
	#define lc (o<<1)
	#define rc (o<<1|1)
	void pushup(int o)
	{
		tr[o].val=tr[lc].val*tr[rc].val;
	}
	void build(int o, int l, int r)
	{
		tr[o].l=l; tr[o].r=r;
		if (l==r) { tr[o].val=w[l]; return; }
		int mid=l+r>>1;
		build(lc, l, mid);
		build(rc, mid+1, r);
		pushup(o);
	}
	void update(int o, int p)
	{
		if (tr[o].l==tr[o].r)
		{
			tr[o].val=w[p];
			return;
		}
		int mid=tr[o].l+tr[o].r>>1;
		if (p<=mid) update(lc, p);
		else update(rc, p);
		pushup(o);
	}
	#undef lc
	#undef rc
} st;
struct Pipe
{
	int x, v, p;
	Pipe() {}
	Pipe(int a, int b, int c): x(a), v(b), p(c) {}
} a[MAXN];
struct Movement
{
	int id, d0, d1;
	Movement() {}
	Movement(int a, int b, int c):
		id(a), d0(b), d1(c) {}
	bool operator < (const Movement& rhs) const
	{
		return 1ll*(a[id].x-a[id-1].x)*(rhs.d0*a[rhs.id-1].v-rhs.d1*a[rhs.id].v)
		      <1ll*(a[rhs.id].x-a[rhs.id-1].x)*(d0*a[id-1].v-d1*a[id].v);
	}
	void set(bool k)
	{
		if (d0==1)
			if (d1==1) w[id].a[0][0]=k*a[id].p;
			else w[id].a[0][1]=k*(1-a[id].p+P)%P;
		else
			if (d1==1) w[id].a[1][0]=k*a[id].p;
			else w[id].a[1][1]=k*(1-a[id].p+P)%P;
	}
	int meettime()
	{
		return 1ll*(a[id].x-a[id-1].x)*inv(d0*a[id-1].v-d1*a[id].v)%P;
	}
} b[4*MAXN];
int main()
{
//	freopen("F.in", "r", stdin);
//	freopen("F.out", "w", stdout);
	int n, m=0;
	scanf("%d", &n);
	a[0]=Pipe(-(1E9+233), 1E6+233, 0);
	for (int i=1; i<=n; i++)
	{
		int x, v, p;
		scanf("%d%d%d", &x, &v, &p);
		a[i]=Pipe(x, v, 1ll*p*INV100%P);
		b[++m]=Movement(i, 1, -1);
		if (a[i].v<a[i-1].v) b[++m]=Movement(i, 1, 1);
		else if (a[i].v>a[i-1].v) b[++m]=Movement(i, -1, -1);
	}
	for (int i=1; i<=n; i++)
	{
		w[i]=Matrix(2, 2);
		w[i].a[0][0]=w[i].a[1][0]=a[i].p;
		w[i].a[0][1]=w[i].a[1][1]=(1-a[i].p+P)%P;
	}
	st.build(1, 1, n);
	sort(b+1, b+m+1);
	int ans=0;
	for (int i=1; i<=m; i++)
	{
		Matrix t=w[b[i].id];
		w[b[i].id]=Matrix(2, 2); b[i].set(1);
		st.update(1, b[i].id);
		ans=(ans+1ll*b[i].meettime()*(st.tr[1].val.a[1][0]+st.tr[1].val.a[1][1]))%P;
		w[b[i].id]=t; b[i].set(0);
		st.update(1, b[i].id);
	}
	printf("%d\n", ans);
	return 0;
}