#割り算が計算に入るのでそれを排除しようと試行錯誤中
def f(e,a,b)
	if e-a<0
		return 0
	else
		if (e-a)%b==0
			return ((e-a)/b)
		else
			return ((e-a)/b)+1
		end
	end
end

def f2(d,m)
	r=10
	res=1
	while d>0 do
 		if d%2==1
 			res=(res*r)%m
 		end
		r=(r*r)%m
 		d/=2
	end
	return res
end


def f3(a, m)
            x = 0
            y = 1
            mgcd = m;
            px = 1
            py = 0
            pgcd = a;
            temp = 0;
            while (mgcd > 0) do
                quotient = pgcd / mgcd;

                temp = x;
                x = px - quotient * temp;
                px = temp;

                temp = y;
                y = py - quotient * temp;
                py = temp;

                temp = mgcd;
                mgcd = pgcd - quotient * temp;
                pgcd = temp;
            end
            return px;
end

ds=gets.split(" ").map{|e| e.to_i}
l=ds[0]
a=ds[1]
b=ds[2]
m=ds[3]

rs=(0..22).map{|e| 10**e}
ts=rs.map{|e| f(e,a,b)}.select{|e| e<=l}
ts<<(l)
ra=1
suma=0
suma2=0
sumb=0
sumb2=0
sumc2=0
mr2=1
#p ts
ts.size.times{|i|
	p1=ts.size-1-i
	p2=p1-1
	if(p2>=0 && ts[p1]>ts[p2])
		p3=rs[p1]
		t3=ts[p1]-ts[p2]
		t4=t3-1
		q0=f2(p1*t3,m)
		q1=f2(p1*t3+p1,m)
		q2=f2(p1,m)
		q3=(q2+(m-1))%m
		q4=(t4*q3)%m
		m10=f3((q3*q3)%m,m)
		m11=f3(q3,m)
		t10=((((q1+(m-q2)+(m-(t3*q3)%m)))%m)*m10)%m
		t11=(((((q0+(m-1))%m)*m11)%m)*(ts[p2]-1))%m
		s10=(((q0+(m-1))%m)*m11)%m
		suma2=((suma2+mr2*s10))%m
		sumb2=((sumb2+mr2*(t10+t11)))%m
		#t3.times{|e|
		#	suma=(suma+ra)%m
		#	sumb=(sumb+ra*l)%m
		#	ra=(ra*p3)%m
		#	l-=1
		#}
		#p [suma,suma2,sumb,sumb2]
		sumc2=(sumc2+(t3*p1))
		mr2=f2(sumc2,m)%m
	end
}
#p ((a*suma+b*sumb)%m)
p ((a*suma2+b*sumb2)%m)