{
    ACM ICPC 2003-2004 NEERC

    Problem:    Jurassic Remains
    Author:     Elena Kryuchkova
    Solution:   Andrew Stankevich
}

program jurassic;

const
    maxn = 24;

var
    n: longint;
    a: array [1..maxn] of longint;
    u, bu: array [1..maxn] of boolean;
    best: longint;


procedure search(i, c, x: longint);
begin
    if i > n then
    begin
        if (x = 0) and (c > best) then
        begin
            best := c;
            bu := u;
        end;
        exit;
    end;

    u[i] := false;
    search(i + 1, c, x);
    u[i] := true;
    search(i + 1, c + 1, x xor a[i]);
end;

var
    i, j, k: longint;
    s: string;
    c: char;

begin

    if eoln then runerror(239);
    read(n);
    if (n < 1) or (n > maxn) then
        runerror(239);
    if not eoln then runerror(239);
    readln;

    for i := 1 to n do
    begin
        if eof or eoln then runerror(239);
        readln(s);

        for j := 1 to length(s) do
            if not (s[j] in ['A'..'Z']) then runerror(239);
        for j := 1 to length(s) do
            for k := j + 1 to length(s) do
                if s[j] = s[k] then
                    runerror(239);

        a[i] := 0;
        for c := 'A' to 'Z' do
        begin
            a[i] := a[i] shl 1;
            if pos(c, s) <> 0 then
                a[i] := a[i] or 1;
        end;
    end;
    if not eof then runerror(239);

    best := 0;
    fillchar(u, sizeof(u), 0);
    fillchar(bu, sizeof(bu), 0);
    search(1, 0, 0);

    writeln(best);
    for i := 1 to n do
    begin
        if bu[i] then
            write(i, ' ');
    end;

    close(input);
    close(output);
end.