var
  r, i, j, k, l, m, n: longint;
  a, b: array [0..100, 0..100] of boolean;
  ut, v: array [0..101] of boolean;
  s, name: string;
  f: boolean;

function try1(x: longint): boolean; forward;

function try2(x: longint): boolean;
var
  i: longint;
begin
  try2 := true;

  if not v[x] then
  begin
    v[x] := true;
    exit;
  end;

  for i := 1 to m do
    if b[i][x] and not ut[i] then
      if try1(i) then
      begin
        b[i][x] := false;
        exit;
      end;
  try2 := false;
end;

function try1(x: longint): boolean;
var
  i: longint;
begin
  ut[x] := true;
  try1 := true;
  for i := 1 to n do
    if a[x][i] then
      if try2(i) then
      begin
        b[x][i] := true;
        exit;
      end;
  try1 := false;
end;

begin
{  assign(input, 'input.txt');
  reset(input);
  assign(output, 'output.txt');
  rewrite(output);}

  read(n);
  if seekeof then;
  readln(name);
  m := length(name);
  for i := 1 to n do
  begin
    readln(s);
    for j := 1 to m do
      for k := 1 to 6 do
        if s[k] = name[j] then
          a[j][i] := true;
  end;

  r := 0;
  for i := 1 to m do
  begin
    fillchar(ut, sizeof(ut), 0);
    if try1(i) then inc(r) else break;
  end;

  if r = m then
  begin
    writeln('YES');
    for i := 1 to m do
      for j := 1 to n do
        if b[i][j] then write(j, ' ');
  end
  else
    writeln('NO');
end.
