local function uf_initialize(n)
  local parent = {}
  for i = 1, n do parent[i] = i end
  return parent
end

local function uf_findroot(idx, parent)
  local idx_update = idx
  while parent[idx] ~= idx do
    idx = parent[idx]
  end
  while parent[idx_update] ~= idx do
    parent[idx_update], idx_update = idx, parent[idx_update]
  end
  return idx
end

local n, m = io.read("*n", "*n")
local lang = {}
for i = 1, m do
  lang[i] = {}
end
for i = 1, n do
  local k = io.read("*n")
  for j = 1, k do
    local l = io.read("*n")
    table.insert(lang[l], i)
  end
end

local parent = uf_initialize(n)
for i = 1, m do
  if 0 < #lang[i] then
    local r = uf_findroot(lang[i][1], parent)
    for j = 2, #lang[i] do
      local tgt = lang[i][j]
      local tr = uf_findroot(tgt, parent)
      parent[tr], parent[tgt] = r, r
    end
  end
end
local cand = uf_findroot(1, parent)
for i = 2, n do
  local z = uf_findroot(i, parent)
  if z ~= cand then print("NO") os.exit() end
end
print("YES")
