function len(t) local r = 0 for k,v in pairs(t) do r = r + 1 end return r end print((function (y, n) for i=0,9 do n[tostring(i)] = true end for _=1,tonumber(io.stdin:read("*l")) do local s = io.stdin:read("*l") if s:sub(9) == "NO" then for e in s:gmatch("%d") do y[e],n[e] = nil,nil end else if next(y) == nil then for e in s:gmatch("%d") do if n[e] ~= nil then y[e] = true end end else for k,_ in pairs(y) do if s:find(k) == nil then y[k],n[k] = nil,nil end end for e in s:gmatch("%d") do if y[e] == nil then n[e] = nil end end end end end return string.format("%s", next(len(y) == 1 and y or n)) end)({}, {}))