Electronic and magnetic properties of La4Ni3−xCuxO8 and Nd4−ySmyNi3O8