Map.fromList $ concatMap (\(y, line) -> map (\(x, f) -> ((x, y), f)) line) $ zip [0 ..] $ map (zip [0 ..]) (lines f)