import Control.Monad
import Control.Applicative

diff :: [Int] -> Int
diff xs = read (head xs) - read (last xs)

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

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