Var k, j, sum:integer;
n,i:longint;
prev,cur, found :boolean;
s:string;
Begin
read(n,k);
for i := 2 to n do begin
s := inttostr(i);
sum := 0;
for j := 1 to length(s) do
sum := sum + strtoint(s[j]);
cur := (sum mod k) = 0;
found := found or (prev and cur);
if prev and cur then
writeln(i - 1,' ',i);
prev := cur;
end;
if not found then writeln('NO');
End.