(*
 * II Всероссийская Командная Олимпиада Школьников по Программированию
 *
 * Задача:      Две Стены
 * Автор:       Андрей Станкевич
 * Решение:     Андрей Станкевич
 *)

{$A+,B-,D+,E+,F-,G+,I+,L+,N+,O-,P+,Q-,R-,S+,T-,V-,X+,Y+}
{$M 65520,0,655360}

program two_walls;

const
    maxk = 100;
    maxl = 100;
    maxm = 50;

var
    i, j, k, l, t, p, n, c, len: longint;
    f: boolean;
    m: array [0..maxk] of longint;
    a, index: array [0..maxk, 0..maxm] of integer;
    can, b: array [0..maxl * maxm] of boolean;
    from: array [0..maxl * maxm] of integer;
    

procedure outp(x, y: longint);
begin
    if from[x] = 0 then
        exit;
    outp(x - a[y][from[x]], y);
    write(index[y][from[x]], ' ');
end;

begin
{    assign(input, 'input.txt');
    reset(input);
    assign(output, 'output.txt');
    rewrite(output);}
    
    read(n, k);
    for i := 1 to n do
    begin
        read(l, c);
        inc(m[c]);
        a[c][m[c]] := l;
        index[c][m[c]] := i;
        t := t + l;
    end;
    t := t div k;
    
    fillchar(can, sizeof(can), true);
    for i := 1 to k do
    begin
        fillchar(b, sizeof(b), false);
        b[0] := true;
        for j := 1 to m[i] do
        begin
            for l := t downto a[i][j] do
                if b[l - a[i][j]] then
                    b[l] := true;
        end;
        for j := 1 to t do
            can[j] := can[j] and b[j];
    end;
    
    f := false;
    for i := 1 to t - 1 do
        if can[i] then
        begin
            f := true;
            len := i;
            break;
        end;
        
    if f then
    begin
        writeln('YES');
        
        for i := 1 to k do
        begin
            fillchar(b, sizeof(b), false);
            fillchar(from, sizeof(from), 0);
            b[0] := true;
            for j := 1 to m[i] do
            begin
                for l := t downto a[i][j] do
                    if (not b[l]) and b[l - a[i][j]] then
                    begin
                        b[l] := true;
                        from[l] := j;
                    end;
            end;
            outp(len, i);
        end;
    end else begin
        writeln('NO');
    end;
    
    close(input);
    close(output);
end.
