  We explore the nature of possible electromagnetic counterparts of
coalescences of massive black hole binaries at cosmological distances
detectable by the Laser Interferometer Space Antenna (LISA). An electromagnetic
precursor, during the last year of gravitational wave (GW)-driven inspiral, or
an afterglow within few years after coalescence, may highlight the position in
the sky of galaxies hosting LISA sources. We show that observations of
precursors and afterglows are mutually exclusive, depending on the mass of the
primary black hole. Precursors are expected to occur in binaries where the
primary (more massive) black hole is heavier than ~10^7 \Msun. They may
correspond to on-off states of accretion, i.e., to a bright X-ray source
decaying into quiescence before black hole coalescence, and are likely
associated to disturbed galaxies showing signs of ongoing starbursts.
Coalescences of lighter binaries, with masses <5x10^6 \Msun, lack of any
precursor, as gas is expected to be consumed long before the GW-driven orbital
decay. Such events would not be hosted by (massive) galaxies with an associated
starburst, given the slow binary inspiral time compared to the typical time
scale of starbursts. By contrast, coalescence, for such light binaries, is
followed by an electromagnetic afterglow, i.e., an off-on accretion state
rising in <20 yrs. Using a cosmological merger tree algorithm, we show that
future X-ray missions such as XEUS will be able to identify, in 20 yrs
operation, almost all the massive BH binary detectable by LISA, and, in only 5
yrs, all the LISA sources at z>6.
