def get_manga_target(flag_id, bitmasks, header):
    """Get MANGA_TARGET[``flag_id``] flag.

    Parameters:
        flag_id (str):
            Flag ID number (e.g., "1" for MANGA_TARGET1).
        bitmasks (dict):
            `Maskbit` objects.
        header (`astropy.io.fits.header.Header`):
            File header.

    Returns:
        `Maskbit`
    """
    flag_id = str(int(flag_id))
    manga_target = bitmasks['MANGA_TARGET{}'.format(flag_id)]

    try:
        manga_target.mask = int(header['MNGTRG{}'.format(flag_id)])
    except KeyError:
        manga_target.mask = int(header['MNGTARG{}'.format(flag_id)])

    return manga_target