local mmi, mma = math.min, math.max local s = io.read() local n = #s local t = {} local inf = 1000000007 for i = 1, 26 do t[i] = {} for j = 1, 26 do t[i][j] = inf end end for i = 1, 26 do local spos = -inf for j = 1, n do local b = s:byte(j) - 96 t[i][b] = mmi(t[i][b], j - spos) if b == i then spos = j end end end for i = 1, 26 do for j = 1, 26 do local z = io.read("*n") local f = z <= t[i][j] io.write(f and "Y" or "N") -- io.write(t[i][j] == inf and "_" or t[i][j]) io.write(j == 26 and "\n" or " ") end end