using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; class TEST{ static void Main(){ Sol mySol =new Sol(); mySol.Solve(); } } class Sol{ public void Solve(){ ulong mod = (ulong) 1e9+7; ulong[] ms = new ulong[N+1]; ms[0] = mod; for(int i=1;i his = new Dictionary(); his.Add(tot,0); List L = new List(); for(int i=0;i0){ tot += ((ulong) k) * ms[a]; tot -= ((ulong) k) * ms[b]; }else if(k<0){ tot -= ((ulong)(-k)) * ms[a]; tot += ((ulong)(-k)) * ms[b]; } res[i+1] = tot; if(!his.ContainsKey(tot)){ his.Add(tot,i+1); } } Console.WriteLine(String.Join("\n",L)); } int N,Q; String[] S; public Sol(){ var d = ria(); N = d[0]; Q = d[1]; S = new String[Q]; for(int i=0;iint.Parse(e));} static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));} static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));} }