#nullable enable using System.Numerics; #region var (_input, _iter) = (Array.Empty(), 0); T I() where T : IParsable { while (_iter >= _input.Length) (_input, _iter) = (Console.ReadLine()!.Split(' '), 0); return T.Parse(_input[_iter++], null); } #endregion static T[] Range(int n, Func F) => Enumerable.Range(0, n).Select(_ => F()).ToArray(); ModInt Solve() { var ps = Range(3, () => Range(3, () => new Rational(I(), 1))); var l = Range(3, () => new Rational(I(), 1)); foreach (var p in ps) { var pz = p[2]; var lz = l[2]; var dz = lz - pz; var k = lz / dz; for (var i = 0; i < 3; i++) { var pi = p[i]; var li = l[i]; var di = li - pi; p[i] = li + di * k; } } for (var i = 1; i < 3; i++) for (var j = 0; j < 3; j++) { ps[i][j] -= ps[0][j]; } var area = (ps[1][0] * ps[2][1] - ps[1][1] * ps[2][0]) / (Int128)2; if (area < (Int128)0) area = -area; var a = (ModInt)(long)(area.P % (Int128)ModInt.Mod); var b = (ModInt)(long)(area.Q % (Int128)ModInt.Mod); return a / b; } var ans = Range(I(), Solve); Console.WriteLine(string.Join(Environment.NewLine, ans)); readonly record struct ModInt { public const int Mod = 998244353; int V { get; init; } public ModInt(long value) { var v = value % Mod; if (v < 0) v += Mod; V = (int)v; } static ModInt New(int value) => new(){ V = value }; public static implicit operator ModInt(long v) => new(v); public static implicit operator int(ModInt modInt) => modInt.V; public static ModInt AdditiveIdentity => New(0); public static ModInt operator +(ModInt a, ModInt b) { var v = a.V + b.V; if (v >= Mod) v -= Mod; return New(v); } public ModInt AdditiveInverse() { if (V == 0) return AdditiveIdentity; return New(Mod - V); } public static ModInt operator -(ModInt a, ModInt b) { var v = a.V - b.V; if (v < 0) v += Mod; return New(v); } public static ModInt MultiplicativeIdentity => New(1); public static ModInt operator *(ModInt a, ModInt b) => New((int)((long)a.V * b.V % Mod)); public ModInt MultiplicativeInverse() => V == 0 ? throw new DivideByZeroException() : Power(V, Mod - 2, Mod); public static ModInt operator /(ModInt a, ModInt b) => a * b.MultiplicativeInverse(); static long Power(long v, ulong p, long mod) { var (res, k) = (1L, v); while (p > 0) { if ((p & 1) > 0) res = res * k % mod; k = k * k % mod; p >>= 1; } return res; } public ModInt Power(long p) => p < 0 ? MultiplicativeInverse().Power(-p) : Power(V, (ulong)p, Mod); public override string ToString() => V.ToString(); } readonly record struct Rational : IAdditiveIdentity, Rational>, IAdditionOperators, Rational, Rational>, ISubtractionOperators, Rational, Rational>, IUnaryNegationOperators, Rational>, IMultiplicativeIdentity, Rational>, IMultiplyOperators, Rational, Rational>, IDivisionOperators, Rational, Rational>, IComparable>, IEqualityOperators, Rational, bool>, IComparisonOperators, Rational, bool> where T : IBinaryInteger { public T P { get; private init; } public T Q { get; private init; } public Rational(T p, T q) { if (q == T.Zero) throw new DivideByZeroException(); if (q < T.Zero) (p, q) = (-p, -q); var (x, y) = (T.Abs(p), q); while (y > T.Zero) (x, y) = (y, x % y); (P, Q) = (p / x, q / x); } public Rational(T p) { (P, Q) = (p, T.One); } public static Rational AdditiveIdentity => new(T.Zero); public static Rational MultiplicativeIdentity => new(T.One); public static implicit operator Rational(T i) => new(i); public static Rational operator -(Rational r) => new(-r.P, r.Q); public static Rational operator +(Rational r1, Rational r2) => new(r1.P * r2.Q + r1.Q * r2.P, r1.Q * r2.Q); public static Rational operator -(Rational r1, Rational r2) => new(r1.P * r2.Q - r1.Q * r2.P, r1.Q * r2.Q); public static Rational operator *(Rational r1, Rational r2) => new(r1.P * r2.P, r1.Q * r2.Q); public static Rational operator /(Rational r1, Rational r2) => new(r1.P * r2.Q, r1.Q * r2.P); public static bool operator <(Rational r1, Rational r2) => r1.CompareTo(r2) < 0; public static bool operator <=(Rational r1, Rational r2) => r1.CompareTo(r2) <= 0; public static bool operator >(Rational r1, Rational r2) => r1.CompareTo(r2) > 0; public static bool operator >=(Rational r1, Rational r2) => r1.CompareTo(r2) >= 0; public int CompareTo(Rational r) => (P * r.Q).CompareTo(Q * r.P); }