import Control.Monad
import Control.Applicative

diff :: [Int] -> Int
diff xs = head xs - last xs


solver :: [[Int]] -> [Int]
solver = fmap diff

main :: IO()
main = do
  inputs <- map (map (read :: String -> Int) . words) <$> replicateM 7 getLine
  mapM_ print $ solver inputs