using CPlibs; using Kzrnm.Competitive.IO; using System; using System.Buffers.Text; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Text; namespace YC373.Problems { internal partial class ProblemD { static void Solve() { var answers = new long[] { 353412483, 499853409, 198066141, 65944976, 0, 0, 83359314, 197704749, 499956396, 461596998, 499924557, 250031589, 66025737, 0, 0, 65922195, 197880351, 395804754, 461671050, 395752629, 197825844, 65951319, 0, 0, 65936360, 197777304, 499639056, 583029498, 395715012, 249552855, 66073349, 0, 0, 66026043, 197876565, 395514645, 582863367, 303214194, 249900573, 66080034, 0, 0, 65941840, 249952551, 395548158, 583092006, 395796816, 250096923, 83408904, 0, 0, 83352606, 197785611, 395734917, 461688090, 395834907, 197910177, 65958885, 0, 0, 83129445, 197879421, 395601315, 583179990, 499975596, 197894460, 83217288, 0, 0, 65851552, 197977152, 395723337, 461598072, 499492386, 151682058, 83391159, 0, 0, 65982393, 197810568, 499698792, 461615477, 499465320, 197929308, 83479962, 0, 0, 66034772, 249868407, 395609340, 461586120, 395850384, 197943681, 65989561, 0, 0, 66018201, 249605913, 395763186, 461545017, 500244135, 250121904, 65992770, 0, 0, 83439696, 197582427, 395906010, 461534357, 395972283, 249747105, 50667829, 0, 0, 65970890, 197840178, 395783145, 582714366, 395839320, 249607272, 66034569, 0, 0, 65970813, 197862537, 499837770, 461586033, 395704725, 197937468, 66025153, 0, 0, 65971953, 197855130, 499324197, 461779937, 395694588, 250272546, 83394459, 0, 0, 65931391, 250137234, 395347209, 461799958, 395664129, 198104688, 83187177, 0, 0, 65844093, 197915487, 395640954, 461877100, 499267476, 197996145, 83116794, 0, 0, 83077128, 197816517, 395716419, 583089981, 395680647, 197847309, 66034770, 0, 0, 65927544, 197856531, 395729877, 582755274, 395784210, 197870754, 83518725, 0, 0, 83482623, 197741811, 500063223, 461407793, 395845749, 197818044, 66124482, 0, 0, 83419152, 197585898, 395806743, 461487779, 396117981, 249519294, 66035306, 0, 0, 83193621, 249380424, 395683833, 461503212, 500027589, 197855943, 65988450, 0, 0, 65930507, 197764092, 395690775, 461566449, 499518105, 197901777, 65986020, 0, 0, 65933772, 250096410, 395624835, 583102701, 395703927, 197915679, 65987298, 0, 0, 50523021, 249970845, 395405595, 461756184, 395565168, 198146163, 83144547, 0, 0, 65983467, 249543381, 499087524, 461617473, 395695518, 250057275, 65957211, 0, 0, 65974043, 197782437, 395546595, 461593956, 395765376, 249800436, 65946828, 0, 0, 83100603, 197759865, 499933236, 461658190, 499637970, 197937693, 65994989, 0, 0, 83165199, 151389405, 499921449, 461545845, 395752965, 197762508, 66111248, 0, 0, 83355123, 197818980, 499370913, 582628467, 395794911, 197844207, 83457036, 0, 0, 66017907, 197835168, 395622237, 461486226, 395661093, 197892921, 83237010, 0, 0, 83211351, 249550986, 395580453, 582788094, 395923029, 249712644, 66025575, 0, 0, 65897514, 249726033, 302922846, 583014219, 395884293, 197863206, 65933645, 0, 0, 65893369, 250099782, 395686374, 582793884, 499733808, 197928006, 66021523, 0, 0, 66010887, 197890128, 395726169, 461611814, 395609376, 197826183, 66037128, 0, 0, 65941779, 249662991, 499401411, 461547663, 499391031, 198039087, 83234613, 0, 0, 66018343, 197644773, 499469412 }; cw.WriteLine(answers[cr.Int() % 333]); } } } #region Dependency resolution namespace YC373.Problems { internal partial class ProblemD { static ConsoleReader cr; static ConsoleWriter cw; #if COMPETITIVE public ProblemD(string outputFilePath = null, bool solving = true) #else static void Main(string[] args) #endif { #if COMPETITIVE SourceExpander.Expander.Expand(outputFilePath: outputFilePath); #endif if (cw != null) cw.Dispose(); cr = new ConsoleReader(); cw = new ConsoleWriter(); #if COMPETITIVE if (solving) #endif Solve(); cw.Dispose(); } } } #endregion #region Expanded by https://github.com/kzrnm/SourceExpander namespace Kzrnm.Competitive.IO{using static Utf8Parser;using _R=ConsoleReader;using MI=System.Runtime.CompilerServices.MethodImplAttribute;public class ConsoleReader{internal const int BufSize=1<<12;internal readonly Stream input;internal readonly Encoding encoding;internal readonly byte[]buf;internal int pos;internal int len;[MI(256)]public ConsoleReader():this(Console.OpenStandardInput(),Console.InputEncoding,BufSize){}[MI(256)]public ConsoleReader(Stream input,Encoding encoding):this(input,encoding,BufSize){}[MI(256)]public ConsoleReader(Stream input,Encoding encoding,int bufferSize){this.input=input;this.encoding=encoding;buf=new byte[bufferSize];}[MI(256)]private void FillEntireNumber(){if((uint)pos>=(uint)buf.Length)FillNextBuffer();while(buf[pos]<=' ')if( ++pos>=len)FillNextBuffer();if(pos+21>=buf.Length&&buf[buf.Length-1]>' ')FillEntireNumberImpl();}private void FillEntireNumberImpl(){buf.AsSpan(pos,len-pos).CopyTo(buf);len-=pos;pos=0;var numberOfBytes=input.Read(buf,len,buf.Length-len);if(numberOfBytes==0)buf[len++]=10;else if(numberOfBytes+len=len)FillNextBuffer();return buf[pos++];}[MI(256)]public T Read(){if(typeof(T)==typeof(int))return(T)(object)Int();if(typeof(T)==typeof(uint))return(T)(object)UInt();if(typeof(T)==typeof(long))return(T)(object)Long();if(typeof(T)==typeof(ulong))return(T)(object)ULong();if(typeof(T)==typeof(double))return(T)(object)Double();if(typeof(T)==typeof(decimal))return(T)(object)Decimal();if(typeof(T)==typeof(char))return(T)(object)Char();if(typeof(T)==typeof(string))return(T)(object)Ascii();return Throw();}static T Throw()=>throw new NotSupportedException(typeof(T).Name);[MI(256)]public int Int(){FillEntireNumber();TryParse(buf.AsSpan(pos),out int v,out int bc);pos+=bc;return v;}[MI(256)]public uint UInt(){FillEntireNumber();TryParse(buf.AsSpan(pos),out uint v,out int bc);pos+=bc;return v;}[MI(256)]public long Long(){FillEntireNumber();TryParse(buf.AsSpan(pos),out long v,out int bc);pos+=bc;return v;}[MI(256)]public ulong ULong(){FillEntireNumber();TryParse(buf.AsSpan(pos),out ulong v,out int bc);pos+=bc;return v;}[MI(256)]public double Double(){FillEntireNumber();TryParse(buf.AsSpan(pos),out double v,out int bc);pos+=bc;return v;}[MI(256)]public decimal Decimal(){FillEntireNumber();TryParse(buf.AsSpan(pos),out decimal v,out int bc);pos+=bc;return v;}[MI(256)]public string String(){var sb=new List();;byte b;do b=ReadByte();while(b<=' ');do{sb.Add(b);b=ReadByte();}while(' '();byte b;do b=ReadByte();while(b<=' ');do{sb.Add(b);b=ReadByte();}while(b!='\n'&&b!='\r');return encoding.GetString(sb.ToArray());}[MI(256)]public char Char(){byte b;do b=ReadByte();while(b<=' ');return(char)b;}[MI(256)]public int Int0()=>Int()-1;[MI(256)]public uint UInt0()=>UInt()-1;[MI(256)]public long Long0()=>Long()-1;[MI(256)]public ulong ULong0()=>ULong()-1;[MI(256)]public static implicit operator int(_R cr)=>cr.Int();[MI(256)]public static implicit operator uint(_R cr)=>cr.UInt();[MI(256)]public static implicit operator long(_R cr)=>cr.Long();[MI(256)]public static implicit operator ulong(_R cr)=>cr.ULong();[MI(256)]public static implicit operator double(_R cr)=>cr.Double();[MI(256)]public static implicit operator decimal(_R cr)=>cr.Decimal();[MI(256)]public static implicit operator string(_R cr)=>cr.Ascii();public T[]Repeat(int count){var arr=new T[count];for(int i=0;i();return arr;}}} namespace Kzrnm.Competitive.IO{using _W=ConsoleWriter;using MI=System.Runtime.CompilerServices.MethodImplAttribute;public sealed partial class ConsoleWriter:IDisposable{private const int BufSize=1<<12;private readonly StreamWriter sw;public StreamWriter StreamWriter=>sw;public ConsoleWriter():this(Console.OpenStandardOutput(),Console.OutputEncoding){}public ConsoleWriter(Stream output,Encoding encoding):this(output,encoding,BufSize){}public ConsoleWriter(Stream output,Encoding encoding,int bufferSize){sw=new StreamWriter(output,encoding,bufferSize);}[MI(256)]public void Flush()=>sw.Flush();[MI(256)]public void Dispose()=>Flush();[MI(256)]public _W Write(T v){sw.Write(v.ToString());return this;}[MI(256)]public _W WriteLine(){sw.WriteLine();return this;}[MI(256)]public _W WriteLine(T v){sw.WriteLine(v.ToString());return this;}[MI(256)]public _W WriteLineJoin(IEnumerablecol)=>WriteMany(' ',col);[MI(256)]public _W WriteLineJoin((T1,T2)tuple)=>WriteLineJoin(tuple.Item1,tuple.Item2);[MI(256)]public _W WriteLineJoin((T1,T2,T3)tuple)=>WriteLineJoin(tuple.Item1,tuple.Item2,tuple.Item3);[MI(256)]public _W WriteLineJoin((T1,T2,T3,T4)tuple)=>WriteLineJoin(tuple.Item1,tuple.Item2,tuple.Item3,tuple.Item4);[MI(256)]public _W WriteLineJoin(TTuple tuple)where TTuple:System.Runtime.CompilerServices.ITuple{var col=new object[tuple.Length];for(int i=0;iWriteMany(' ',col);[MI(256)]public _W WriteLineJoin(T1 v1,T2 v2){sw.Write(v1.ToString());sw.Write(' ');sw.WriteLine(v2.ToString());return this;}[MI(256)]public _W WriteLineJoin(T1 v1,T2 v2,T3 v3){sw.Write(v1.ToString());sw.Write(' ');sw.Write(v2.ToString());sw.Write(' ');sw.WriteLine(v3.ToString());return this;}[MI(256)]public _W WriteLineJoin(T1 v1,T2 v2,T3 v3,T4 v4){sw.Write(v1.ToString());sw.Write(' ');sw.Write(v2.ToString());sw.Write(' ');sw.Write(v3.ToString());sw.Write(' ');sw.WriteLine(v4.ToString());return this;}[MI(256)]public _W WriteLines(IEnumerablecol)=>WriteMany('\n',col);[MI(256)]public _W WriteGrid(IEnumerable>cols){foreach(var col in cols)WriteLineJoin(col);return this;}[MI(256)]public _W WriteGrid(IEnumerabletuples)where TTuple:System.Runtime.CompilerServices.ITuple{foreach(var tup in tuples)WriteLineJoin(tup);return this;}[MI(256)]private _W WriteMany(char sep,IEnumerablecol){var en=col.GetEnumerator();if(!en.MoveNext())goto End;sw.Write(en.Current.ToString());while(en.MoveNext()){sw.Write(sep);sw.Write(en.Current.ToString());}End:sw.WriteLine();return this;}}} namespace Kzrnm.Competitive.IO{using MI=System.Runtime.CompilerServices.MethodImplAttribute;public partial class ConsoleWriter{[MI(256)]public ConsoleWriter WriteLine(ReadOnlySpanv){sw.WriteLine(v);return this;}[MI(256)]public ConsoleWriter WriteLineJoin(Spancol)=>WriteMany(' ',(ReadOnlySpan)col);[MI(256)]public ConsoleWriter WriteLineJoin(ReadOnlySpancol)=>WriteMany(' ',col);[MI(256)]public ConsoleWriter WriteLines(Spancol)=>WriteMany('\n',(ReadOnlySpan)col);[MI(256)]public ConsoleWriter WriteLines(ReadOnlySpancol)=>WriteMany('\n',col);[MI(256)]private ConsoleWriter WriteMany(char sep,ReadOnlySpancol){var en=col.GetEnumerator();if(!en.MoveNext())return this;sw.Write(en.Current.ToString());while(en.MoveNext()){sw.Write(sep);sw.Write(en.Current.ToString());}sw.WriteLine();return this;}}} namespace CPlibs { using MI = System.Runtime.CompilerServices.MethodImplAttribute; public static class Calc { [MI(256)] public static void Swap(ref T value1, ref T value2) { var temp = value1; value1 = value2; value2 = temp; } [MI(256)] public static bool Range(int value, int min, int max) { return min <= value && value <= max; } [MI(256)] public static bool Range(long value, long min, long max) { return min <= value && value <= max; } [MI(256)] public static long CeilDiv(long x, long y) { return (x + (y - 1)) / y; } [MI(256)] public static long Clamp(long value, long min, long max) { return Math.Min(Math.Max(value, min), max); } [MI(256)] public static long Xor(params long[] values) { if (values.Length == 0) return 0; long xored = values[0]; for (int i = 1; i < values.Length; i++) xored ^= values[i]; return xored; } [MI(256)] public static bool Chmin(ref T value1, params T[] valuesMany) where T : IComparable { bool swapped = false; foreach (var value2 in valuesMany) if (value1.CompareTo(value2) > 0) { swapped = true; value1 = value2; } return swapped; } [MI(256)] public static bool Chmax(ref T value1, params T[] valuesMany) where T : IComparable { bool swapped = false; foreach (var value2 in valuesMany) if (value1.CompareTo(value2) < 0) { swapped = true; value1 = value2; } return swapped; } [MI(256)] public static T[] Init1dArray(int x, T initialValue = default(T)) { var res = new T[x]; for (int i = 0; i < x; i++) res[i] = initialValue; return res; } [MI(256)] public static T[][] Init2dArray(int x, int y, T initialValue = default(T)) { var res = new T[x][]; for (int i = 0; i < x; i++) { res[i] = new T[y]; for (int j = 0; j < y; j++) res[i][j] = initialValue; } return res; } [MI(256)] public static T[][][] Init3dArray(int x, int y, int z, T initialValue = default(T)) { var res = new T[x][][]; for (int i = 0; i < x; i++) { res[i] = new T[y][]; for (int j = 0; j < y; j++) { res[i][j] = new T[z]; for (int k = 0; k < z; k++) res[i][j][k] = initialValue; } } return res; } [MI(256)] public static T[][][][] Init4dArray(int x, int y, int z, int w, T initialValue = default(T)) { var res = new T[x][][][]; for (int i = 0; i < x; i++) { res[i] = new T[y][][]; for (int j = 0; j < y; j++) { res[i][j] = new T[z][]; for (int k = 0; k < z; k++) { res[i][j][k] = new T[w]; for (int l = 0; l < w; l++) { res[i][j][k][l] = initialValue; } } } } return res; } } } namespace SourceExpander{public class Expander{[Conditional("EXP")]public static void Expand(string inputFilePath=null,string outputFilePath=null,bool ignoreAnyError=true){}public static string ExpandString(string inputFilePath=null,bool ignoreAnyError=true){return "";}}} #endregion Expanded by https://github.com/kzrnm/SourceExpander