processors =2

model=crcw


def sum[3][9]

def prefixsum[3][9]
def answer[3]


i=1
t=1
thingplus%=pid*2
thing%=thingplus%-1

sum[t][thing%]=thing%
sum[t][thingplus%]=thingplus%




call dosum
sync
call doprefix
firstel=1
answer% = prefixsum[firstel][pid]



proc doprefix
{	
	r=1
	j=2
	round=2
	while (r<=j)
	{	
		if (pid <=r)
		{
			nextround=round+1			
			if (pid==1)
			{
				val%=sum[round][pid]
				prefixsum[round][pid]=val%						
			} else {
		
				f%=pid
				call iseven

				if (t%==1)
				{					
					indexy%=pid/2	
					tempval%=prefixsum[nextround][indexy%]				
					prefixsum[round][pid]=tempval%
				} else {					
					indexy%=pid-1
					indexy%=indexy%/2
					valueofit%=prefixsum[nextround][indexy%]
					upval%=sum[round][pid]
					valueofit%=valueofit%+upval%
					prefixsum[round][pid]=valueofit%
				}
			}
			
		}
	sync
	round--	
	r=r*2
	
	}
}

proc dosum
{
	round=1
	k=0

	while (i>=pid)
	{
	
		nextround=round+1		

		one%=sum[round][thing%]
		two%=sum[round][thingplus%]
		resultsum%=one%+two%

		sum[nextround][pid]=resultsum%

		call testifwasodd
		
		
		b=i
		i=i/2
		round++

		call testeven	

		
	}
}

proc testifwasodd
{
	if (k==1)	
	{
		if (pid==i)
		{
			sum[nextround][pid]=sum[round][thing%]
		}
	}	
}

proc testeven
{
	c=b.2		
	if (c!=0)
	{
		if (i!=0)
		{	
			i++
			k=1
		}
	} else {

		k=0
	}
}

proc iseven
{
	t%=1
	f%=f%.2
	if (f%!=0)
	{
		t%=0
	}
}
