/SPdict 40 dict def 
SPdict begin

/cycol 3 def
/mgcol 2 def
/ylcol 1 def
/kycol 0 def
/colour kycol def
/UCRB .5 def
/UCRM .31 def
/UCRY .48 def
/setgray {colour 0 eq
 {systemdict begin setgray end}
 {pop systemdict begin 1 setgray end}
 ifelse
}def
/bd{bind def}bind def
/setrgbcolor{colour 0 eq{3 copy 1 index eq 3 1 roll eq and
   {pop pop systemdict begin setgray end}
   {do_ucrblack systemdict begin setgray end pop pop pop}ifelse}
   {3 copy 1 index eq 3 1 roll eq and{pop pop pop systemdict begin 1 setgray end}
   {do_ucrblack pop do_correct colour 1 sub index systemdict begin setgray end
   pop pop pop }ifelse}ifelse}def
currentdict /setcmykcolor known not{
 /setcmykcolor{dup 5 -1 roll add dup 1 gt{pop 1}if
  1 exch sub 4 1 roll dup 4
 -1 roll add dup 1 gt{pop 1}if
  1 exch sub 3 1 roll add dup 1 gt{pop 1}if
  1 exch sub setrgbcolor}bd}if
/sethsbcolor{systemdict begin sethsbcolor
  currentrgbcolor end userdict begin setrgbcolor end}def
/do_correct{cvtrgbcym 1 index UCRY mul sub 3 1 roll 1
  index UCRM mul sub 3 1 roll 3 1 roll cvtrgbcym}def
/do_ucrblack{cvtrgbcym min 3 index min
/mincolour exch def pop pop
/ucramt mincolour UCRB sub dup 0 lt
{pop 0}if def ucramt sub 3 1 roll ucramt sub 3 1 roll ucramt sub 3 1 roll
cvtrgbcym ucramt 1.25 mul 1 exch sub}def
/cvtrgbcym{
1 exch sub 3 1 roll
1 exch sub 3 1 roll
1 exch sub 3 1 roll}def
/min{2 copy lt{1}{0}ifelse index}def

end
