local n, m, k = io.read("*n", "*n", "*n") local t = {} for i = 1, m do local a = io.read("*n") if a <= k then table.insert(t, a) end end for i = 2, n do local tbl = {} for j = 1, m do local a = io.read("*n") for p = 1, #t do if a + t[p] <= k then tbl[a + t[p]] = true end end end t = {} for k, _u in pairs(tbl) do table.insert(t, k) end end table.sort(t) if #t == 0 then print(-1) else print(k - t[#t]) end