Problem:
Score : 100 points

Problem Statement

You are given two integer arrays a_0, a_1, ..., a_{N - 1} and b_0, b_1, ..., b_{M - 1}. Calculate the array c_0, c_1, ..., c_{(N - 1) + (M - 1)}, defined by c_i = \sum_{j = 0}^i a_j b_{i - j} \bmod 998244353.

Constraints

1 \leq N, M \leq 524288

0 \leq a_i, b_i < 998244353

All values in Input are integer.

Input

Input is given from Standard Input in the following format:

N M
a_0 a_1 ... a_{N-1}
b_0 b_1 ... b_{M-1}

Output

Print the answer in the following format:

c_0 c_1 ... c_{(N - 1) + (M - 1)}

Sample Input 1

4 5
1 2 3 4
5 6 7 8 9

Sample Output 1

5 16 34 60 70 70 59 36

Sample Input 2

1 1
10000000
10000000

Sample Output 2

871938225

Solution in C# (.NET Core 3.1.201) (judge verdict: Accepted)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

//using System.Numerics;
using CS=System.Runtime.CompilerServices;
//using System.Diagnostics;
using static System.Math;
using ll=System.Int64;
using static Contest_F.Lib_IO;
using static Contest_F.Lib_Minifunc;


namespace Contest_F {

public static class Entry
{

	public static void Main() {
		checked{
			long n, m;
			Lib_IO.rm(out n, out m);
			ll[] a,b;
			ra(out a);
			ra(out b);

			var ans = NTTWrapper.Multiply(a,b,998244353);

			Lib_IO.wa(ans);
		}
	}

public static class NTTWrapper {
	static readonly long[] _nttmods;
	static readonly NumberTheoreticTransform[] _nttcalc;

	static NTTWrapper(){
		_nttmods = new long[] {
			2025848833,	// n=22 k=483 b=31 o=5
			2088763393,	// n=23 k=249 b=31 o=5
			2013265921,	// n=27 k=15 b=31 o=11
			1811939329,	// n=26 k=27 b=31 o=11
			2113929217,	// n=25 k=63 b=31 o=5
			2130706433,	// n=24 k=127 b=31 o=3
		};

		_nttcalc = new NumberTheoreticTransform[_nttmods.Length];
		for (int i = 0; i < _nttcalc.Length; i++) _nttcalc[i] = new NumberTheoreticTransform(_nttmods[i]);
	}

	public static long[] Multiply(long[] A, long[] B, long mod=long.MaxValue) {
		long maxa = 0;
		long maxb = 0;
		for (int i = 0; i < A.Length; i++) if(maxa<A[i]) maxa = A[i];
		for (int i = 0; i < B.Length; i++) if(maxb<B[i]) maxb = B[i];
		double maxv = Math.Log(maxa)+Math.Log(maxb)+Math.Log(Math.Min(A.Length,B.Length));
		int mlen = 0;
		double mprod = 0.0;
		for (int i = 0; i < _nttmods.Length; i++) {
			mprod += Math.Log(_nttmods[i]);
			mlen++;
			if(maxv<mprod) break;
		}

		long[] ret;
		if(mlen==1&&mprod<Math.Log(mod)){
			ret = _nttcalc[0].Multiply(A, B);
		}else{
			long[][] CC = new long[mlen][]; 
			for (int i = 0; i < mlen; i++) CC[i] = _nttcalc[i].Multiply(A, B);
			ret = new long[CC[0].Length];
			long[] vals = new long[mlen];
			long[] mods = new long[mlen];
			Array.Copy(_nttmods, mods, mlen); 
			for (int j = 0; j < CC[0].Length; j++) {
				for (int i = 0; i < mlen; i++) vals[i] = CC[i][j];
				ret[j] = Garner(vals, mods, mod);
			}
		}
		return ret;
	}


}

public class NumberTheoreticTransform {
	private long[] _rts = {0, 1};
	private int[] _rev = {0, 1};
	private int _bas = 1;
	private readonly int _maxbas;
	private readonly long _mod, _root;

	public NumberTheoreticTransform() : this(1012924417) {}
	public NumberTheoreticTransform(long modulo) {
		if (modulo < 3 || modulo % 2 == 0) throw new ArgumentException("Invalid modulo", "modulo");
		_mod = modulo;
		long tmp = _mod - 1;
		_maxbas = 0;
		while(tmp % 2 == 0) {
			tmp >>= 1;
			_maxbas++;
		}
		long prim_root = 2;
		while(mod_pow(prim_root, (_mod - 1) >> 1) == 1) ++prim_root;
		if (mod_pow(prim_root, _mod - 1) != 1) throw new ArgumentException("Invalid prim_root", "prim_root");
		_root = mod_pow(prim_root, (_mod - 1) >> _maxbas);
	}

	private void ensure_base(int N) {
		if(N<=_bas) return;
		Array.Resize(ref _rts, 1<<N);
		Array.Resize(ref _rev, 1<<N);
		for(int i = 0; i < (1 << N); i++) _rev[i] = (_rev[i >> 1] >> 1) + ((i & 1) << (N - 1)); 
		if (_maxbas < N) throw new ArgumentException("Invalid nbase", "N");
		while(_bas < N) {
			long z = mod_pow(_root, 1L << (_maxbas - 1 - _bas));
			for(int i = 1 << (_bas - 1); i < (1 << _bas); i++) {
				_rts[i << 1] = _rts[i];
				_rts[(i << 1) + 1] = mul(_rts[i], z);
			}
			++_bas;
		}
	}

	[CS.MethodImpl(256)] private long mod_pow(long x, long n) {
		long ret = 1;
		while(n > 0) {
			if(0<(n & 1)) ret = mul(ret, x);
			x = mul(x, x);
			n >>= 1;
		}
		return ret;
	}
//	[CS.MethodImpl(256)] private long mod_pow(System.Numerics.BigInteger x, System.Numerics.BigInteger n) => (long)System.Numerics.BigInteger.ModPow(x, n, _mod);

	[CS.MethodImpl(256)] private long inverse(long x) => mod_pow(x, _mod - 2);
	[CS.MethodImpl(256)] private long add(long x, long y) {
		x += y;
		if(x >= _mod) x -= _mod;
		return x;
	}

	[CS.MethodImpl(256)] private long mul(long a, long b) => checked(a * b) % _mod;
//	[CS.MethodImpl(256)] private long mul(System.Numerics.BigInteger a, System.Numerics.BigInteger b) => (long)(a * b % _mod);
//	[CS.MethodImpl(256)] private long mul(long a, long b) {	// BigInteger より遅い (long:1 BinInt:3 decimal:5  FFT(double):0.6 )
//		long c = (a * b - (long)((decimal) a * b / _mod) * _mod) % _mod;
//		return c < 0 ? c + _mod : c;
//	}

	public void NTT(long[] F) {
		int n = F.Length;
		if ((n & (n - 1)) != 0) throw new ArgumentException("Invalid size", "n");
		int zeros = 0;
		if(0<n){
			int nn = n;
			while((nn&1)==0){
				zeros++;
				nn>>=1;
			}
		}
		ensure_base(zeros);
		int shift = _bas - zeros;
		for(int i = 0; i < n; i++) {
			int j = (_rev[i] >> shift);
			if(i < j) { var t = F[j]; F[j] = F[i]; F[i] = t; }
		}
		for(int k = 1; k < n; k <<= 1) {
			for(int i = 0; i < n; i += 2 * k) {
				for(int j = 0; j < k; j++) {
					var z = mul(F[i + j + k], _rts[j + k]);
					F[i + j + k] = add(F[i + j], _mod - z);
					F[i + j] = add(F[i + j], z);
				}
			}
		}
	}

	public long[] Multiply(long[] A, long[] B) {
		int need = A.Length + B.Length - 1;
		int nbase = 1;
		while((1 << nbase) < need) nbase++;
		ensure_base(nbase);
		int sz = 1 << nbase;
		var da = new long[sz];
		var db = new long[sz];
		for (int i = 0; i < A.Length; i++) da[i] = A[i];
		for (int i = 0; i < B.Length; i++) db[i] = B[i];
		NTT(da);
		NTT(db);
		var inv_sz = inverse(sz);
		var dc = new long[sz];
		dc[0] = mul(da[0], mul(db[0], inv_sz));
		for(int i = 1; i < sz; i++) dc[sz-i] = mul(da[i], mul(db[i], inv_sz));
		NTT(dc);
		Array.Resize(ref dc, need);
		return dc;
	}

}


	//	最大公約数・最小公倍数
	//	http://kumikomiya.com/competitive-programming-with-c-sharp/
	public static long GCD(long a, long b) {
		while (b != 0) { var t = b; b = a % b; a = t; }
		return a;
	}
	public static long GCD(params long[] z) { long v = z[0]; for(int i=1;i<z.Length;i++) v = GCD(v, z[i]); return v; }
	public static long LCM(long a, long b) => checked(a / GCD(a, b) * b);
	public static long LCM(params long[] z) { long v = z[0]; try{ for(int i=1;i<z.Length;i++) v = LCM(v, z[i]); }catch{ v=long.MaxValue; } return v; }

	
	// 拡張ユークリッドの互除法   返り値: a と b の最大公約数  ax + by = gcd(a, b) を満たす (x, y) が格納される
	public static long EGCD(long a, long b, out long x, out long y) {
		x = 0; y = 1;
		long u = 1 , v = 0, gcd = 0;
		while (a != 0) {
			var q = b / a; var r = b % a; var m = x - u * q; var n = y - v * q;
			b = a; a = r; x = u; y = v; u = m; v = n; gcd = b;
		}
		return gcd;
	}

	// 逆元
	public static long ModInv(long value, long modulo) {
		long x, y;
		if (1 != EGCD(value, modulo, out x, out y)) throw new ArgumentException("Invalid modulo", "modulo");
		return (x < 0)?x+modulo:x;
	}
	
	// 繰り返し２乗法
	public static long Pow(long x, long n, long m=long.MaxValue) {
		long ret = 1;
		while (true) {
			if ((n & 1) == 1) ret = (ret * x) % m;
			if((n >>= 1)<=0) break;
			x = (x * x) % m;
		}
		return ret;
	}

	// 約数列挙
	public static long[] Divisor(long n) {
		var ret1 = new List<long>();
		var ret2 = new List<long>();
		long i2;
		for(long i = 1; (i2 = i*i) <= n; i++) {
			if(n % i == 0) {
				ret1.Add(i);
				if(i2 != n) ret2.Add(n / i);
			}
		}
		long[] ret = new long[ret1.Count+ret2.Count];
		for (int i = 0; i < ret1.Count; i++) ret[i] = ret1[i];
		for (int i = ret2.Count-1; 0 <= i; i--) ret[ret1.Count+ret2.Count-i-1] = ret2[i];
		return ret;
	}

	// 素因数分解（素数判定）
	public static long[] PrimeFactor(long n) {
		var ret = new List<long>();
		if (n < 2) return ret.ToArray();
		while ((n & 1) == 0) {
			ret.Add(2);
			n >>= 1;
		}
		while ((n % 3) == 0) {
			ret.Add(3);
			n /= 3;
		}
		long sqi = Convert.ToInt64(Math.Sqrt(n));
		while(sqi*sqi<=n) sqi++;
		for (long i = 5, f = 2; i < sqi; i += f, f ^= 6) {
			while ((n % i) == 0) {
				ret.Add(i);
				n /= i;
			}
			if(n==1) break;
		}
		if(1<n) ret.Add(n);
		return ret.ToArray();
	}
	// osak法　自然数 nの素因数分解を O(logn) で行う．ただし，エラトステネスを前処理として行う必要があるので，時間 O(kloglogk)，空間 O(k) の前処理が必要 (k は n の最大値)．
	// http://web.archive.org/web/20161103144433/http://www.osak.jp/diary/diary_201310.html
	public static long[][] PrimeFactor(long[] a) {
		long n = a.Max();
		bool[] is_prime = Enumerable.Repeat(true,(int)n+1).ToArray();
		long[] min_factor = new long[n+1];
		is_prime[0] = is_prime[1] = false;
		min_factor[0] = 0;
		min_factor[1] = 1;
		long i1, i2;
		for(i1 = 2; (i2 = i1 * i1) <= n; ++i1) {
			if(is_prime[i1]) {
				min_factor[i1] = i1;
				for(long j = i2; j < is_prime.Length; j += i1) {
					is_prime[j] = false;
					if(min_factor[j] == 0) min_factor[j] = i1;
				}
			}
		}
		for(long i = i1; i <= n; ++i) if(is_prime[i]) min_factor[i] = i;
		var ret = new long[a.Length][];
		for(int k=0; k<a.Length; k++) {
			var prime_list = new List<long>();
			long tmp = a[k];
			while(tmp > 1) {
				long fact = min_factor[tmp];
				tmp /= fact;
				prime_list.Add(fact);
			}
			ret[k] = prime_list.ToArray();
		}
		return ret;
	}
	
	// 素数テーブル（エラトステネスの篩）
	public static bool[] PrimeTable(long n) {
		bool[] e = Enumerable.Repeat(true, (int)n+1).ToArray();
		if(n >= 0) e[0] = false;
		if(n >= 1) e[1] = false;
		for(int j = 4; j < e.Length; j += 2) e[j] = false;
		for(int j = 9; j < e.Length; j += 6) e[j] = false;
		long i2;
		for(long i = 5, g = 2; (i2 = i * i) <= n; i += g, g ^= 6) {
			if(e[i]) for(long j = i2; j < e.Length; j += i * 2) e[j] = false;
		}
		return e;
	}
	public static long[] PrimeList(long n) {
		var l = new List<long>();
		if(n<2) return l.ToArray();
		l.Add(2);
		if(n<3) return l.ToArray();
		l.Add(3);
		bool[] e = PrimeTable(n);
		for (long i = 5, g = 2; i < e.Length; i += g, g ^= 6) if(e[i]) l.Add(i);
		return l.ToArray();
	}

	// Garner のアルゴリズム,連立合同式を解く x%MOD, LCM%MOD を求める
	// https://qiita.com/drken/items/ae02240cd1f8edfc86fd
	public static long Garner(long[] b, long[] m, long MOD=9223372036854775783L) {
		long lcm;
		if((lcm = PreGarner(ref b, ref m, MOD))==-1) return -1;	// 前処理不要ならコメントアウト
		var q = new long[m.Length+1];
		Array.Copy(m,q,m.Length);
		q[q.Length-1] = MOD; // 番兵
		long[] coeffs = Enumerable.Repeat(1L,q.Length).ToArray();
		long[] constants = Enumerable.Repeat(0L,q.Length).ToArray();
		for (int k = 0; k < b.Length; ++k) {
			long t = (b[k] - constants[k]) * ModInv(coeffs[k], q[k]) % q[k];
			t += (t<0)?q[k]:0;
			for (int i = k+1; i < q.Length; ++i) {
				constants[i] = (constants[i] + t * coeffs[i]) % q[i];
				coeffs[i] = (coeffs[i] * q[k]) % q[i];
			}
		}
		return constants[constants.Length-1];
	}
	// Garner のアルゴリズムの前処理 mが互いに素ではない場合
	public static long PreGarner(ref long[] b, ref long[] m, long MOD=9223372036854775783L) {
		for (int i = 0; i < b.Length; ++i) {
			for (int j = 0; j < i; ++j) {
				long g = GCD(m[i], m[j]);
				// これを満たさなければ解はない
				if ((b[i] - b[j]) % g != 0) return -1;
				// s = m[i], t = m[j] を仮想的に素因数分解して s = p^k ... q^l ..., t = q^m ... r^n ... となったときに
				m[i] /= g; // p については i の方が大きかったものについての j との差分、と q
				m[j] /= g; // p については j の方が大きかったものについての i との差分、と r
				// 残る g を i と j に振り分ける (i の方が指数大きかった素因子 p の分は最終的に gi に、j の方が指数大きかった素因子 p の分は最終的に gj に)
				// ひとまず j 側にある p については gj のみに行くようにする
				long gi = GCD(m[i], g), gj = g/gi;
				// 本来 i 側に行くべき p で gj 側にあるものを gi 側に寄せていく
				do {
					g = GCD(gi, gj);
					gi *= g; gj /= g;
				} while (g != 1);
				// i 側と j 側に戻していく
				m[i] *= gi; m[j] *= gj;
				// m[i] と m[j] が元より小さくなったのに合わせて余りも計算し直しておく
				b[i] %= m[i]; b[j] %= m[j];
			}
		}
		var bb = new List<long>();
		var mm = new List<long>();
		for (int i = 0; i < b.Length; i++)
		{
			if(1<m[i]){
				bb.Add(b[i]);
				mm.Add(m[i]);
			}
		}
		b = bb.ToArray();
		m = mm.ToArray();
		long lcm = 1;
		for (int i = 0; i < b.Length; ++i) lcm = (lcm * m[i]) % MOD;
		return lcm;
	}

	// 離散対数問題  a^x=b mod m を満たす非負整数 x の最小値を求める。
	// Baby-step Giant-step 法 O(sqrt(m))
	public static long ModLog(long a, long b, long m) {
		long ok = m, ng = -1;
		while(ok - ng > 1) {
			var mid = (ok + ng) / 2;
			if(mid * mid >= m) ok = mid;
			else ng = mid;
		}
		Dictionary<long, long> baby = new Dictionary<long, long>((int)ok);
		long factor = 1;
		for(long i = 0, e = b; i < ok; i++) {
			baby[e] = i;
			factor = (factor * a) % m;
			e = (e * a) % m;
		}
		for(long i = 1, e = factor; i <= ok; i++) {
			if(baby.ContainsKey(e)) return i * ok - baby[e];
			e = (e * factor) % m;
		}
		return -1;
	}

	// ルジャンドル記号
	// a≥0 が奇素数 p を法として平方剰余であれば 1、そうでなければ −1、a が p で割り切れる場合は 0 を返します。
	public static long Legendre(long a, long p) {
		long ret = Pow(a, (p-1)/2, p);
		if (ret == p-1) ret = -1;
		return ret;
	}

	// Tonelli–Shanks algorithm　　calculate R such that R^2 = n (mod p)  p is a prime
	// See http://en.wikipedia.org/wiki/Tonelli%E2%80%93Shanks_algorithm
	public static long ModSqrt(long n, long p) {
		if(p <2) return -1;
		if(p==2) return n;
		long r = Legendre(n, p);
		if(r!=1) return r;
		
		// step 1
		long Q = p-1;
		long S = 0;
		while ((Q & 1) == 0) {
			++S;
			Q >>= 1;
		}
		if (S == 1) return Pow(n, (p+1)/4, p);

		// step 2
		long z = 1;
		var rnd = new System.Random();
		int rm = int.MaxValue <= p ? int.MaxValue : (int)p+1;
	    while (Legendre(z, p) != -1)  z = rnd.Next(rm);
		long c = Pow(z, Q, p);
		
		// step 3
		long R = Pow(n, (Q+1)/2, p);
		long t = Pow(n, Q, p);
		long M = S;

		// step 4
		while (t != 1) {
			long i;
			long t2 = t;
			for (i = 1; i < M; i++) {
				t2 = t2 * t2 % p;
				if (t2 == 1) break;
			}
			long b = Pow(c, 1L<<(int)(M-i-1), p);
			R = R * b % p;
			t = (t * b % p) * b % p;
			c = b * b % p;
			M = i;
		}
		
		return R;
	}















}



#region BaseModule


public static class Lib_Minifunc{
	public const long MOD1 = 1000000007; // 10^9+7
	public const double EPS1 = 1e-8;
	public const long INF1 = 1000000000000000;  // 10^15
	[CS.MethodImpl(256)] public static void swap1<T>(ref T a,ref T b) { T t = a; a = b; b = t; }
	[CS.MethodImpl(256)] public static void swap2<T>(ref T a,ref T b) where T : IComparable { if (a.CompareTo(b)==1) swap1(ref a, ref b); }  // b の方が小さければ交換

	[CS.MethodImpl(256)] public static bool chmin<T>(ref T a,T b) where T : IComparable { bool r; if (r = (a.CompareTo(b)== 1)) a = b; return r; }  // b の方が小さければ a を更新
	[CS.MethodImpl(256)] public static bool chmax<T>(ref T a,T b) where T : IComparable { bool r; if (r = (a.CompareTo(b)==-1)) a = b; return r; }  // b の方が大きければ a を更新
	[CS.MethodImpl(256)] public static bool inside(long i,long n) => (0<=i&&i<n);
	[CS.MethodImpl(256)] public static bool inside(long x,long y,long w,long h) => (inside(x,w)&&inside(y,h));
	[CS.MethodImpl(256)] public static T min<T>(params T[] a) where T : IComparable { T m = a[0]; for (int i=1;i<a.Length;i++) chmin(ref m, a[i]); return m; }
	[CS.MethodImpl(256)] public static T max<T>(params T[] a) where T : IComparable { T m = a[0]; for (int i=1;i<a.Length;i++) chmax(ref m, a[i]); return m; }
	[CS.MethodImpl(256)] public static long mod(long a,long m=MOD1) { var v = a%m; return (v<0?(m<0?v-m:v+m):v); }
	[CS.MethodImpl(256)] public static long ceil(long a,long b) => (a%b==0||(a<0&&0<b)||(0<a&&b<0)?a/b:a/b+1);	// 整数商の切り上げ
	[CS.MethodImpl(256)] public static long round(double a) => Convert.ToInt64(a);	// 四捨五入
	public static string YES(bool a) => a?"YES":"NO";
	public static string yes(bool a) => a?"Yes":"No";
	[CS.MethodImpl(256)] public static P<T,U> initp<T,U>(T a,U b) => new P<T,U>(a,b);
	[CS.MethodImpl(256)] public static P<T,U,V> initp<T,U,V>(T a,U b,V c) => new P<T,U,V>(a,b,c);
	[CS.MethodImpl(256)] public static P<T,U,V,W> initp<T,U,V,W>(T a,U b,V c,W d) => new P<T,U,V,W>(a,b,c,d);
	public static T[] initc<T>(long l1) where T : new() { var m = new T[l1]; for (int i=0;i<m.Length;i++) m[i] = new T(); return m; }	// new制約は遅い
	public static int[] range(long s, long c) => Enumerable.Range((int)s,(int)c).ToArray();
	[CS.MethodImpl(256)] public static T[] inita<T>(long l1,T v=default(T)) => Enumerable.Repeat(v,(int)l1).ToArray();
	public static T[][] inita<T>(long l1,long l2,T v=default(T)) { var m = new T[l1][]; for (int i=0;i<m.Length;i++) m[i] = inita(l2,v); return m; }
	public static void shift(this IList<int> l,int o) { for (int i = 0;i<l.Count;i++) l[i]+=o; }
	public static void shift(this IList<long> l,long o) { for (int i = 0;i<l.Count;i++) l[i]+=o; }
	[CS.MethodImpl(256)] public static bool initd<T,U>(this IDictionary<T,U> d, T k, U v=default(U)) { if(d.ContainsKey(k)) { return false; } else { d[k] = v; return true; } }
	public static void sort<T>(this T[] a,int o=1, Comparison<T> f=null) where T : IComparable {
		switch(o){
			case  0: Array.Sort(a,f);break;
			case  1: Array.Sort(a,(x,y)=>x.CompareTo(y));break;
			case -1: Array.Sort(a,(x,y)=>y.CompareTo(x));break;
			default: break;
		}
	}
	public static void sort<T,U>(this P<T,U>[] a,int o, Comparison<P<T,U>> f=null) where T : IComparable where U : IComparable {
		switch(o){
			case  0: Array.Sort(a,f);break;
			case  1: Array.Sort(a,(x,y)=>x.A.CompareTo(y.A));break;
			case -1: Array.Sort(a,(x,y)=>y.A.CompareTo(x.A));break;
			case  2: Array.Sort(a,(x,y)=>x.B.CompareTo(y.B));break;
			case -2: Array.Sort(a,(x,y)=>y.B.CompareTo(x.B));break;
			default: break;
		}
	}
	public static void sort<T,U,V>(this P<T,U,V>[] a,int o, Comparison<P<T,U,V>> f=null) where T : IComparable where U : IComparable where V : IComparable {
		switch(o){
			case  0: Array.Sort(a,f);break;
			case  1: Array.Sort(a,(x,y)=>x.A.CompareTo(y.A));break;
			case -1: Array.Sort(a,(x,y)=>y.A.CompareTo(x.A));break;
			case  2: Array.Sort(a,(x,y)=>x.B.CompareTo(y.B));break;
			case -2: Array.Sort(a,(x,y)=>y.B.CompareTo(x.B));break;
			case  3: Array.Sort(a,(x,y)=>x.C.CompareTo(y.C));break;
			case -3: Array.Sort(a,(x,y)=>y.C.CompareTo(x.C));break;
			default: break;
		}
	}
	public static void sort<T,U,V,W>(this P<T,U,V,W>[] a,int o, Comparison<P<T,U,V,W>> f=null) where T : IComparable where U : IComparable where V : IComparable where W : IComparable {
		switch(o){
			case  0: Array.Sort(a,f);break;
			case  1: Array.Sort(a,(x,y)=>x.A.CompareTo(y.A));break;
			case -1: Array.Sort(a,(x,y)=>y.A.CompareTo(x.A));break;
			case  2: Array.Sort(a,(x,y)=>x.B.CompareTo(y.B));break;
			case -2: Array.Sort(a,(x,y)=>y.B.CompareTo(x.B));break;
			case  3: Array.Sort(a,(x,y)=>x.C.CompareTo(y.C));break;
			case -3: Array.Sort(a,(x,y)=>y.C.CompareTo(x.C));break;
			case  4: Array.Sort(a,(x,y)=>x.D.CompareTo(y.D));break;
			case -4: Array.Sort(a,(x,y)=>y.D.CompareTo(x.D));break;
			default: break;
		}
	}
}


public struct P<T,U>
{
	public T A; public U B;
	public P(T a,U b) { A = a; B = b; }
	public static implicit operator KeyValuePair<T,U>(P<T,U> a) => new KeyValuePair<T,U>(a.A,a.B);
	public static implicit operator P<T,U>(KeyValuePair<T,U> a) => new P<T,U>(a.Key,a.Value);
}
public struct P<T,U,V>
{
	public T A; public U B; public V C;
	public P(T a,U b,V c) { A = a; B = b; C = c; }
}
public struct P<T,U,V,W>
{
	public T A; public U B; public V C; public W D;
	public P(T a,U b,V c,W d) { A = a; B = b; C = c; D = d; }
}

public static class Lib_IO
{
	class Prt : System.IO.StreamWriter
	{
		public override IFormatProvider FormatProvider { get { return System.Globalization.CultureInfo.InvariantCulture; } }
		public Prt(System.IO.Stream s) : base(s,new UTF8Encoding(false,true)) {}
		public Prt(System.IO.Stream s,Encoding e) : base(s,e) {}
	}
	static Prt sw = new Prt(Console.OpenStandardOutput());
	static char[] sp = new char[] {' '};
	[CS.MethodImpl(256)] static bool eq<T,U>() => typeof(T).Equals(typeof(U));
	[CS.MethodImpl(256)] static T ct<T,U>(U a) => (T)Convert.ChangeType(a,typeof(T));
	[CS.MethodImpl(256)] static T cv<T>(string s) =>
		eq<T,int>()	? ct<T,int>(int.Parse(s))
	  : eq<T,long>()   ? ct<T,long>(long.Parse(s))
	  : eq<T,double>() ? ct<T,double>(double.Parse(s,System.Globalization.CultureInfo.InvariantCulture))
	  : eq<T,char>()   ? ct<T,char>(s[0])
					   : ct<T,string>(s);
	public static string[] rm<T>(out T a) {
		var z = Console.ReadLine().Split(sp,StringSplitOptions.RemoveEmptyEntries); 
		a = cv<T>(z[0]);
		return z;
	}
	public static string[] rm<T,U>(out T a,out U b) {
		var z = rm<T>(out a); 
		b = cv<U>(z[1]);
		return z;
	}
	public static string[] rm<T,U,V>(out T a,out U b,out V c) {
		var z = rm<T,U>(out a,out b); 
		c = cv<V>(z[2]);
		return z;
	}
	public static string[] rm<T,U,V,W>(out T a,out U b,out V c,out W d) {
		var z = rm<T,U,V>(out a,out b,out c); 
		d = cv<W>(z[3]);
		return z;
	}
	public static string[] rm<T,U,V,W,X>(out T a,out U b,out V c,out W d,out X e) {
		var z = rm<T,U,V,W>(out a,out b,out c,out d); 
		e = cv<X>(z[4]);
		return z;
	}
	public static string[] rm<T,U,V,W,X,Y>(out T a,out U b,out V c,out W d,out X e,out Y f) {
		var z = rm<T,U,V,W,X>(out a,out b,out c,out d,out e); 
		f = cv<Y>(z[5]);
		return z;
	}
	public static string[] ra<T>(out T[] a) {		
		var z = Console.ReadLine().Split(sp,StringSplitOptions.RemoveEmptyEntries);
		a = new T[z.Length];
		for(int i=0;i<a.Length;i++) a[i] = cv<T>(z[i]);
		return z;
	}
	public static string[][] rl<T>(long n,out T[] a) {
		a = new T[n];
		var y = new string[n][];
		for(int i=0;i<n;i++) y[i] = rm(out a[i]);
		return y;
	}
	public static string[][] rl<T,U>(long n,out P<T,U>[] a) {
		a = new P<T,U>[n];
		var y = new string[n][];
		for(int i=0;i<n;i++) {
			T o; U p;
			y[i] = rm(out o,out p);
			a[i] = new P<T,U>(o,p);
		}
		return y;
	}
	public static string[][] rl<T,U,V>(long n,out P<T,U,V>[] a) {
		a = new P<T,U,V>[n];
		var y = new string[n][];
		for(int i=0;i<n;i++) {
			T o; U p; V q;
			y[i] = rm(out o,out p,out q);
			a[i] = new P<T,U,V>(o,p,q);
		}
		return y;
	}
	public static string[][] rl<T,U,V,W>(long n,out P<T,U,V,W>[] a) {
		a = new P<T,U,V,W>[n];
		var y = new string[n][];
		for(int i=0;i<n;i++) {
			T o; U p; V q; W r;
			y[i] = rm(out o,out p,out q,out r);
			a[i] = new P<T,U,V,W>(o,p,q,r);
		}
		return y;
	}
	public static string[][] rx<T>(long n,out T[][] a) {
		a = new T[n][];
		var y = new string[n][];
		for(int i=0;i<n;i++) y[i] = ra(out a[i]);
		return y;
	}

	static void wwp(Action act){
		sw.AutoFlush = false;
		Console.SetOut(sw);
		act();
		Console.Out.Flush();
		sw.AutoFlush = true;
		Console.SetOut(sw);
	}
	[CS.MethodImpl(256)] static string wfm(Type t) =>t.Equals(typeof(double)) ? "{0:F10}" : "{0}";
	public static void wm(params object[] a) {
		wwp(()=>{
			for(int i=0;i<a.Length-1;i++) Console.Write(wfm(a[i].GetType())+" ",a[i]);
			Console.WriteLine(wfm(a[a.Length-1].GetType()),a[a.Length-1]);
		});
	}
	public static void wa<T>(IList<T> a) { wxa(new IList<T>[]{a}, " "); }
	public static void wl<T>(IList<T> a) {
		wwp(()=>{
			var f = wfm(typeof(T));
			if(a.Count==0){
				Console.WriteLine();
			}else{
				foreach(T x in a) Console.WriteLine(f,x);
			}
		});
	}
	static void wxa<T>(IList<IList<T>> a, string s) {
		wwp(()=>{
			var f = wfm(typeof(T));
			var g = f + s;
			foreach(var b in a) {
				if(b.Count==0){
					Console.WriteLine();
				}else{
					for(int i=0;i<b.Count-1;i++) Console.Write(g,b[i]);
					Console.WriteLine(f,b[b.Count-1]);
				}
			}
		});
	}
	public static void wx<T>(IList<IList<T>> a) { wxa(a, " "); }
	public static void wg<T>(IList<IList<T>> a) { wxa(a, ""); }
}

#endregion



}