pnPlacesToTrans :: Monad m => PN m value -> DM.Map PlaceNo ([TransNo], [TransNo])
    pnPlacesToTrans pn = DM.fromList $ map combine $ sortAndGroupByElem fst $
        concatMap transToIOPlaces $ DM.assocs $ pnTrans pn
        where
            combine (placeNo, trans) = (placeNo, (concat ins, concat outs))
                where (ins, outs) = unzip $ map snd trans

            transToIOPlaces (transNo, trans) =
                (map (\placeNo -> (placeNo, ([], [transNo]))) $ transInPlaces trans) ++
                (map (\placeNo -> (placeNo, ([transNo], []))) $ transOutPlaces trans)
pnPlacesToTrans :: Monad m => PN m value -> DM.Map PlaceNo ([TransNo], [TransNo])
pnPlacesToTrans pn = DM.fromList $ map combine $ sortAndGroupByElem fst $
        concatMap transToIOPlaces $ DM.assocs $ pnTrans pn
        where
            combine (placeNo, trans) = (placeNo, (concat ins, concat outs))
                where (ins, outs) = unzip $ map snd trans

            transToIOPlaces (transNo, trans) =
                (map (\placeNo -> (placeNo, ([], [transNo]))) $ transInPlaces trans) ++
                (map (\placeNo -> (placeNo, ([transNo], []))) $ transOutPlaces trans)
pnPlacesToTrans pn = DM.fromList $ map combine $ sortAndGroupByElem fst $
        concatMap transToIOPlaces $ DM.assocs $ pnTrans pn
        where
            combine (placeNo, trans) = (placeNo, (concat ins, concat outs))
                where (ins, outs) = unzip $ map snd trans

            transToIOPlaces (transNo, trans) =
                (map (\placeNo -> (placeNo, ([], [transNo]))) $ transInPlaces trans) ++
                (map (\placeNo -> (placeNo, ([transNo], []))) $ transOutPlaces trans)