{-# LANGUAGE FlexibleContexts #-}

module Main where

import Debug.Trace
import Data.List
import qualified Data.Set as Set
import qualified Data.Sequence as Seq
import qualified Data.ByteString.Char8 as B
import Data.Int
import Data.Word
import Data.Char
import Data.Bits
-- import Data.Array
import Data.Array.Unboxed
-- import Data.Array.IO
import Data.Maybe
-- import qualified Data.Map as M
import qualified Data.IntMap as M
-- import Control.Monad.ST
-- import Data.STRef
import Data.Ord
import Data.Functor
import Control.Applicative
import Control.Monad
import Text.Printf

solver :: B.ByteString -> B.ByteString -> [Int]
solver w s = iter 0 0 [] where
    iter j k ac
        | j >= ls = reverse ac
        | B.index s j == B.index w k = if k + 1 >= lw
                                            then iter (j+1) (tbl!(k+1)) ((j-k):ac)
                                            else iter (j+1) (k+1) ac
        | tbl!k < 0 = iter (j+1) (tbl!k +1) ac
        | otherwise = iter j (tbl!k) ac
    ls = B.length s
    lw = B.length w
    tbl :: UArray Int Int
    tbl = iter 1 0 $ array (0, lw) [(0,-1)] where
        iter p c t 
            | p >= lw = t // [(p, c)]
            | B.index w p == B.index w c = iter (p+1) (c+1) (t // [(p, t!c)])
            | otherwise = iter (p+1) (c'+1) t' where
                c' = iter c where
                    iter c
                        | c < 0 || B.index w p == B.index w c = c 
                        | otherwise = iter (t'!c)
                t' = t // [(p, c)]

main :: IO() 
main = do
    s <- B.getLine
    w <- B.getLine
    mapM_ print $ solver w s

